From b5191a2c1fa8f4ce45e36258942c6157a3799e7a Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Thu, 20 Apr 2023 14:13:31 -0600 Subject: [PATCH] Let user "Save As..." when document has been externally modified Currently Okular stops the user from saving their document if it has unsaved changes and was modified externally. This makes some sense because there are now two sources of truth, and Okular cannot reconcile them itself. However as a consequence, it causes data loss since the user's unsaved changes in Okular become un-save-able. This is quite frustrating when it happens. But this prohibiton on saving over an externally-modified document only really makes sense for a "Save" operation that overwrites the original document. If instead, the user does a "Save As...", then they can save their local changes to another file and avoid losing unsaved changes. Then if needed, they can manually compare the original externally-modified document with their newly-saved document and reconcile the changes by hand. Accordingly, this commit avoids showing the error message box and blocking saving if the user is doing a "Save As..." to a new location, rather than overwriting the open file. BUG: 402017 FIXED-IN: 23.04.1 --- part/part.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/part/part.cpp b/part/part.cpp index c6301fd73..e8171d58e 100644 --- a/part/part.cpp +++ b/part/part.cpp @@ -2645,7 +2645,9 @@ bool Part::saveAs(const QUrl &saveUrl, SaveAsFlags flags) // TODO When we get different saving backends we need to query the backend // as to if it can save changes even if the open file has been modified, // since we only have poppler as saving backend for now we're skipping that check - if (m_fileLastModified != QFileInfo(localFilePath()).lastModified()) { + // Don't warn the user about external changes if they're doing a Save As with a different URL, since then there's nothing to warn about + // because the original changed document is safe. + if (m_fileLastModified != QFileInfo(localFilePath()).lastModified() && saveUrl == realUrl()) { KMessageBox::error(widget(), i18n("The file '%1' has been modified by another program, which means it can no longer be saved.", url().fileName()), i18n("File Changed")); return false; }