mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-13 05:01:30 +00:00
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:
parent
4defea8674
commit
a0135a3c8e
8
part.cpp
8
part.cpp
|
@ -1548,6 +1548,9 @@ void Part::slotDoFileDirty()
|
||||||
// do the following the first time the file is reloaded
|
// do the following the first time the file is reloaded
|
||||||
if ( m_viewportDirty.pageNumber == -1 )
|
if ( m_viewportDirty.pageNumber == -1 )
|
||||||
{
|
{
|
||||||
|
// store the url of the current document
|
||||||
|
m_oldUrl = url();
|
||||||
|
|
||||||
// store the current viewport
|
// store the current viewport
|
||||||
m_viewportDirty = m_document->viewport();
|
m_viewportDirty = m_document->viewport();
|
||||||
|
|
||||||
|
@ -1567,17 +1570,16 @@ void Part::slotDoFileDirty()
|
||||||
}
|
}
|
||||||
|
|
||||||
// close and (try to) reopen the document
|
// close and (try to) reopen the document
|
||||||
KUrl oldUrl = url();
|
|
||||||
|
|
||||||
if ( !closeUrl() )
|
if ( !closeUrl() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( KParts::ReadWritePart::openUrl( oldUrl ) )
|
if ( KParts::ReadWritePart::openUrl( m_oldUrl ) )
|
||||||
{
|
{
|
||||||
// on successful opening, restore the previous viewport
|
// on successful opening, restore the previous viewport
|
||||||
if ( m_viewportDirty.pageNumber >= (int) m_document->pages() )
|
if ( m_viewportDirty.pageNumber >= (int) m_document->pages() )
|
||||||
m_viewportDirty.pageNumber = (int) m_document->pages() - 1;
|
m_viewportDirty.pageNumber = (int) m_document->pages() - 1;
|
||||||
m_document->setViewport( m_viewportDirty );
|
m_document->setViewport( m_viewportDirty );
|
||||||
|
m_oldUrl = KUrl();
|
||||||
m_viewportDirty.pageNumber = -1;
|
m_viewportDirty.pageNumber = -1;
|
||||||
m_document->setRotation( m_dirtyPageRotation );
|
m_document->setRotation( m_dirtyPageRotation );
|
||||||
if ( m_sidebar->currentIndex() != m_dirtyToolboxIndex && m_sidebar->isItemEnabled( m_dirtyToolboxIndex )
|
if ( m_sidebar->currentIndex() != m_dirtyToolboxIndex && m_sidebar->isItemEnabled( m_dirtyToolboxIndex )
|
||||||
|
|
1
part.h
1
part.h
|
@ -263,6 +263,7 @@ class Part : public KParts::ReadWritePart, public Okular::DocumentObserver, publ
|
||||||
// document watcher (and reloader) variables
|
// document watcher (and reloader) variables
|
||||||
KDirWatch *m_watcher;
|
KDirWatch *m_watcher;
|
||||||
QTimer *m_dirtyHandler;
|
QTimer *m_dirtyHandler;
|
||||||
|
KUrl m_oldUrl;
|
||||||
Okular::DocumentViewport m_viewportDirty;
|
Okular::DocumentViewport m_viewportDirty;
|
||||||
bool m_wasPresentationOpen;
|
bool m_wasPresentationOpen;
|
||||||
int m_dirtyToolboxIndex;
|
int m_dirtyToolboxIndex;
|
||||||
|
|
Loading…
Reference in a new issue