[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [okular] /: Fix reload of modified documents that take longer to be ready
From:       Fabio D'Urso <fabiodurso () hotmail ! it>
Date:       2012-11-30 23:14:31
Message-ID: 20121130231431.14FA3A6091 () git ! kde ! org
[Download RAW message or body]

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 == -1 )
     {
+        // store the url of the current document
+        m_oldUrl = url();
+
         // store the current viewport
         m_viewportDirty = m_document->viewport();
 
@@ -1567,17 +1570,16 @@ void Part::slotDoFileDirty()
     }
 
     // close and (try to) reopen the document
-    KUrl oldUrl = 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 >= (int) m_document->pages() )
             m_viewportDirty.pageNumber = (int) m_document->pages() - 1;
         m_document->setViewport( m_viewportDirty );
+        m_oldUrl = KUrl();
         m_viewportDirty.pageNumber = -1;
         m_document->setRotation( m_dirtyPageRotation );
         if ( m_sidebar->currentIndex() != m_dirtyToolboxIndex && \
                m_sidebar->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 \
Okular::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;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic