Commit 6691401e authored by Fabio D'Urso's avatar Fabio D'Urso

Fix file swapping after saving to a remote URL

parent 68d5f0af
......@@ -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
{
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment