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
This commit is contained in:
Fabio D'Urso 2012-11-30 23:24:19 +01:00
parent 4defea8674
commit a0135a3c8e
2 changed files with 6 additions and 3 deletions

View file

@ -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 )

1
part.h
View file

@ -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;