Le 08/02/2025 à 18:56, Pavel Sanda a écrit :
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(-)

This fails to build in C++11 mode (ms suffix is a C++14 thing).

../../stable/src/Buffer.cpp: In member function ‘void lyx::Buffer::Impl::fileExternallyModified(bool)’: ../../stable/src/Buffer.cpp:5787:45: error: unable to find numeric literal operator ‘operator""ms’
 5787 |                 std::this_thread::sleep_for(200ms);
      |                                             ^~~~~
../../stable/src/Buffer.cpp:5787:45: note: use ‘-fext-numeric-literals’ to enable more built-in suffixes

JMarc


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-devel mailing list
lyx-devel@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to