commit c8319a1f7e434b9cf55802a70d6cdad8facbf377
Author: Pavel Sanda <sa...@lyx.org>
Date:   Sat Feb 8 18:55:00 2025 +0100

    Backport 2a771febd1a (last fix for #12819 - check for deleted documents)
---
 src/Buffer.cpp | 28 ++++++++++++++++++++--------
 status.24x     |  3 +++
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index e1e10e86c6..fa4a45262b 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -5764,14 +5764,26 @@ void Buffer::Impl::fileExternallyModified(bool const 
exists)
        // Dirty buffers must be visible at all times.
        if (wa_ && wa_->unhide(owner_)) {
                wa_->updateTitles();
-               if (!exists) {
-                       lyx_clean = false;
-                       frontend::Alert::warning(
-                               _("File deleted from disk"),
-                               bformat(_("The file\n  %1$s\n"
-                                          "has been deleted from disk!"),
-                                       from_utf8(filename.absFileName())));
-               }
+
+               if (exists)
+                       return;
+               //Essentially the same problem as in FileMonitorGuard::refresh.
+               //'exists' is not reliable marker of file removal here, e.g.
+               //file overwrite often causes short-term removal, see #12819.
+               std::this_thread::sleep_for(200ms);
+               FileName refreshf (filename.absFileName());
+               //Only double check with delay will trigger warning
+               if(refreshf.exists())
+                       return;
+
+               lyx_clean = false;
+               wa_->updateTitles();
+               frontend::Alert::warning(
+                       _("File deleted from disk"),
+                       bformat(_("The file\n  %1$s\n"
+                                  "has been deleted from disk!\n"
+                                  "It will be marked as modified now."),
+                               from_utf8(filename.absFileName())));
        }
        else
                // Unable to unhide the buffer (e.g. no GUI or not current View)
diff --git a/status.24x b/status.24x
index 2919dae1c6..2974b32f11 100644
--- a/status.24x
+++ b/status.24x
@@ -66,6 +66,9 @@ What's new
 - Japanese default quote style for direct input (not via IME) is changed to
   english.
 
+- Improve detection of removed documents. We did not distinguish between
+  rewrite and removal in some cases (bug 12819).
+
 
 * USER INTERFACE
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to