From 3f552fc26eb8482aabf00d8771230a6141c416f5 Mon Sep 17 00:00:00 2001 From: Nicolas Arnaud-Cormos Date: Tue, 9 Sep 2025 17:56:54 +0200 Subject: [PATCH] fix: file changed externally triggers the message all the time When a file is changed both internally and externally, a dialog shows up on focus to ask to reload and lose the changes. If the answer was no, the same dialog would have appeared again on the next focus. It's now fixed, the dialog shows up only once. Fix #252 --- src/core/document.cpp | 9 +++++++-- src/core/document.h | 1 + src/gui/mainwindow.cpp | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/core/document.cpp b/src/core/document.cpp index fc346a6d..7af75372 100644 --- a/src/core/document.cpp +++ b/src/core/document.cpp @@ -144,11 +144,16 @@ bool Document::hasChangedOnDisk() const return true; } -void Document::reload() +void Document::clearChangedOnDisk() { - doLoad(m_fileName); const QFileInfo fi(m_fileName); m_lastModified = fi.lastModified(); +} + +void Document::reload() +{ + doLoad(m_fileName); + clearChangedOnDisk(); emit fileUpdated(); } diff --git a/src/core/document.h b/src/core/document.h index 4f470349..d6ec4655 100644 --- a/src/core/document.h +++ b/src/core/document.h @@ -61,6 +61,7 @@ class Document : public QObject bool hasChanged() const; bool hasChangedOnDisk() const; + void clearChangedOnDisk(); void reload(); public slots: diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 53de9a1e..eb38441a 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -505,6 +505,9 @@ void MainWindow::reloadDocuments() if (result == QMessageBox::Yes) { for (auto *document : conflictDocs) document->reload(); + } else { + for (auto *document : conflictDocs) + document->clearChangedOnDisk(); } }