From kde-commits Fri Nov 30 23:14:31 2012 From: Fabio D'Urso Date: Fri, 30 Nov 2012 23:14:31 +0000 To: kde-commits Subject: [okular] /: Fix reload of modified documents that take longer to be ready Message-Id: <20121130231431.14FA3A6091 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=135431728319003 Git commit a0135a3c8ec64d1e5325091a7294de84365a6f4f by Fabio D'Urso. Committed on 30/11/2012 at 23:24. Pushed by fabiod into branch 'master'. Fix reload of modified documents that take longer to be ready SlotDoFileDirty tries to reload the file at regular intervals. This patch fixes it so that it can actually reopen the file even if it is not ready at the first timer shot. BUG: 310531 M +5 -3 part.cpp M +1 -0 part.h http://commits.kde.org/okular/a0135a3c8ec64d1e5325091a7294de84365a6f4f diff --git a/part.cpp b/part.cpp index e38efc8..41908ed 100644 --- a/part.cpp +++ b/part.cpp @@ -1548,6 +1548,9 @@ void Part::slotDoFileDirty() // do the following the first time the file is reloaded if ( m_viewportDirty.pageNumber =3D=3D -1 ) { + // store the url of the current document + m_oldUrl =3D url(); + // store the current viewport m_viewportDirty =3D m_document->viewport(); = @@ -1567,17 +1570,16 @@ void Part::slotDoFileDirty() } = // close and (try to) reopen the document - KUrl oldUrl =3D url(); - if ( !closeUrl() ) return; = - if ( KParts::ReadWritePart::openUrl( oldUrl ) ) + if ( KParts::ReadWritePart::openUrl( m_oldUrl ) ) { // on successful opening, restore the previous viewport if ( m_viewportDirty.pageNumber >=3D (int) m_document->pages() ) m_viewportDirty.pageNumber =3D (int) m_document->pages() - 1; m_document->setViewport( m_viewportDirty ); + m_oldUrl =3D KUrl(); m_viewportDirty.pageNumber =3D -1; m_document->setRotation( m_dirtyPageRotation ); if ( m_sidebar->currentIndex() !=3D m_dirtyToolboxIndex && m_sideb= ar->isItemEnabled( m_dirtyToolboxIndex ) diff --git a/part.h b/part.h index adac19a..0c57560 100644 --- a/part.h +++ b/part.h @@ -263,6 +263,7 @@ class Part : public KParts::ReadWritePart, public Okula= r::DocumentObserver, publ // document watcher (and reloader) variables KDirWatch *m_watcher; QTimer *m_dirtyHandler; + KUrl m_oldUrl; Okular::DocumentViewport m_viewportDirty; bool m_wasPresentationOpen; int m_dirtyToolboxIndex;