From 6691401ea602e140ffee120dde68bf4e41abc31e Mon Sep 17 00:00:00 2001 From: Fabio D'Urso Date: Sun, 11 May 2014 12:23:37 +0200 Subject: [PATCH] Fix file swapping after saving to a remote URL --- part.cpp | 21 +++++++++++---------- part.h | 1 + 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/part.cpp b/part.cpp index 8e5c82725..0d9994149 100644 --- a/part.cpp +++ b/part.cpp @@ -1488,8 +1488,17 @@ bool Part::openFile() return true; } -bool Part::openUrl(const KUrl &_url) +bool Part::openUrl( const KUrl &url ) { + return openUrl( url, false /* swapInsteadOfOpening */ ); +} + +bool Part::openUrl( const KUrl &_url, bool swapInsteadOfOpening ) +{ + /* Store swapInsteadOfOpening, so that closeUrl and openFile will be able + * to read it */ + m_swapInsteadOfOpening = swapInsteadOfOpening; + // Close current document if any if ( !closeUrl() ) return false; @@ -2434,18 +2443,10 @@ bool Part::saveAs( const KUrl & saveUrl, bool saveAsOkularArchive ) { if ( m_document->canSwapBackingFile() ) { - // If the generator supports hot-swapping of the backing file - // tell openFile to swap the backing file instead of opening a new one - m_swapInsteadOfOpening = true; - // this calls openFile internally, which in turn actually calls // m_document->swapBackingFile() instead of the regular loadDocument - if ( !openUrl( saveUrl ) ) + if ( !openUrl( saveUrl, true /* swapInsteadOfOpening */ ) ) reloadedCorrectly = false; - - // restore it back to false -- this has already been done by - // openFile, but let's do it again for extra safety - m_swapInsteadOfOpening = false; } else { diff --git a/part.h b/part.h index 821867619..41bfc6c4f 100644 --- a/part.h +++ b/part.h @@ -234,6 +234,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc void noticeMessage( const QString &message, int duration = -1 ); private: + bool openUrl( const KUrl &url, bool swapInsteadOfOpening ); void setupViewerActions(); void setViewerShortcuts(); void setupActions();