On Tue, Aug 20, 2024 at 09:43:28AM +0200, Pavel Sanda wrote: > On Mon, Aug 19, 2024 at 07:17:42PM -0400, Richard Kimberly Heck wrote: > > On 8/19/24 3:44 PM, Pavel Sanda wrote: > > > On Mon, Aug 19, 2024 at 11:15:50AM -0400, Richard Kimberly Heck wrote: > > > > On 8/19/24 9:38 AM, Pavel Sanda wrote: > > > > > On Mon, Aug 19, 2024 at 11:21:37AM +0200, Jean-Marc Lasgouttes wrote: > > > > > > I do not remember such a deliberate changel, but I may have missed > > > > > > it (or we'll find out that I did it on purpose and forgot about it > > > > > > ????). > > > > > It looks as unintended change of 5b2b0d5c76cf2. Riki? > > > > Not intended. Fine with me to go back to the old behavior. > > > Ok, attached is my proposal. I flag the document only in the case > > > of file deletion, not just the external change. > > > Seems to work with in my testing. > > > > > > If you are OK with it, I'll commit to master and branch.' > > > > Simple enough! > > Fixed by e322ef153d.
Unf we need to look again on the document removal detection feature introduced via #12819. Long story short - rewrite of the file (external editor, rsync, another lyx instance, etc) often works via short-lived temporary removal of the file and triggers our new detection mechanism unnecessarily + flag it as modified on top of it. Attached patch solves it via 100ms delay for double checking the file is indeed gone. I admit I do not like the patch much, but I do not see better option (except of reverting this whole new feature - that's also fine with me). Both patch and more details are in #12819, but since it touches delicate part of our code it's better to announce on the list before committing. Any comment/improvements appreciated. Pavel
diff --git a/src/Buffer.cpp b/src/Buffer.cpp index f9ad2dcd6b..65239927f4 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -5681,14 +5681,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(100ms); + 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)
-- lyx-devel mailing list lyx-devel@lists.lyx.org https://lists.lyx.org/mailman/listinfo/lyx-devel