nedit-ng icon indicating copy to clipboard operation
nedit-ng copied to clipboard

false file modified externally notification

Open marilmanen opened this issue 4 years ago • 18 comments

Here is a sequence which gives a false notification of external modification. Functionality is same with old nedit.

echo 1 > file
nedit-ng file &
mv file file_new
# press cancel on the "File not found" dialog
# make modification in nedit-ng to the file and save-as file_new
# press yes on the dialog "file_new already exists"
# now you should get the false dialog "file_new has been modified by another program"

marilmanen avatar Oct 19 '19 05:10 marilmanen

Interesting find, this may take a bit to figure out the logic flow on this one.

eteran avatar Nov 07 '19 16:11 eteran

So there's a pretty easy fix to this one... maybe.

Basically if we change line 2089 of DocumentWidget from:

if (!silent && ((info_->lastModTime != 0 && info_->lastModTime != statbuf.st_mtime) || info_->fileMissing)) {

to

if (!silent && ((info_->lastModTime != 0 && info_->lastModTime != statbuf.st_mtime)  && !info_->fileMissing)) {

Then this warning goes away, I think.

I don't know if the warning was the intended behavior because it is explicitly considering a "missing file" (a file that was deleted while open in nedit) as being "modified". Honestly, that seems like a mistake to me. So I'm going to think about it and see what if any circumstances this makes sense in. And if I can't think of much, well, then I'll have a fix for this!

eteran avatar Dec 10 '20 23:12 eteran

The old nedit seems to have the similar code, but does not have the same problem. I wonder if the issue is lying elsewhere.

if (!silent && 
        ((window->lastModTime != 0 && 
          window->lastModTime != statbuf.st_mtime) ||
         window->fileMissing)  ){

tksoh avatar Dec 11 '20 03:12 tksoh

So yea, the code is taken more or less straight from nedit-5.6. Are you sure it doesn't happen wit the old nedit? The OP says:

"Functionality is same with old nedit."

eteran avatar Dec 11 '20 15:12 eteran

I just tried nedit again, and I didn't get the "file_new has been modified by another program" dialog.

Using the stock nedit install with apt on linux mint 19.3:

NEdit released by Debian (1:5.7-2)

Built on: Linux, x86-64, GNU C With Motif: 2.3.4 [@(#)Motif Version 2.3.4] Running Motif: 2.3 [@(#)Motif Version 2.3.8] Server: The XFree86 Project, Inc 40300000 Visual: 16-bit TrueColor (ID 0x24, Default) Locale: en_US.UTF-8

tksoh avatar Dec 12 '20 05:12 tksoh

OK. Here's something interesting. I tried the latest nedit-ng also, and again, I don't get that last dialog. Hm...

tksoh avatar Dec 12 '20 05:12 tksoh

Hmm, are you sure that you are following the reproduction steps exactly?

eteran avatar Dec 13 '20 01:12 eteran

Yea, I just walked through the steps with nedit-5.6 compiled from source and I get the same exact error:

image

eteran avatar Dec 13 '20 01:12 eteran

I don't know why, but I still don't get that "modified by other program" with nedit 5.6. What am I missing?

2020-12-13 14_31_42-acer (tksoh-Aspire-SW5-012_1 (tksoh)) - VNC Viewer 2020-12-13 14_27_56-acer (tksoh-Aspire-SW5-012_1 (tksoh)) - VNC Viewer 2020-12-13 14_28_15-acer (tksoh-Aspire-SW5-012_1 (tksoh)) - VNC Viewer

tksoh avatar Dec 13 '20 06:12 tksoh

So weird.

Where are you pulling the source from? Is it possible that it has a patch?

eteran avatar Dec 13 '20 07:12 eteran

nedit-git$ git describe --dirty --tags --always REL-5-6

nedit-git$ git log -1 commit c7f38d7ba17fb3d3ea2315163030c24512396660 (HEAD -> 5.6, tag: REL-5-6) Author: Scott Tringali [email protected] Date: Sun Dec 7 17:05:04 2014 -0500

Remove unintended merge conflict

tksoh avatar Dec 13 '20 07:12 tksoh

@sjtringali Any thoughts on this one? Any explanation for the explicit inclusion of a missing file as "modified"?

eteran avatar Dec 13 '20 22:12 eteran

I think we can replace most of this with QFilesystemWatcher. Polling it on focus wasn't never the best thing.

sjtringali avatar Dec 26 '20 18:12 sjtringali

I found a new way to get false externally modified file notification (with version 783cd9a)

  1. create many empty files f1 to f18 (at least this is enough for me)
  2. nedit-ng f*
  3. File/New
  4. SaveAs xxx (sorted tabs, so this will be the last tab)
  5. Close most of the f# files by clicking the Close Tab
  6. type "s" to you xxx file
  7. press Ctrl+S
  8. press Enter (sometimes requires more typing)

marilmanen avatar Feb 05 '21 05:02 marilmanen

I have not got two times a false " has been modified by another program" pop-up message in normal daily work with version caa194d, so I though that could notify that the problem still exists.

For debug purposes I created a new file and a dummy macro

Alt+K
a
<enter>
Ctrl+S
Alt+K

and then I just kept Ctrl and K keys down until the problem occurs. At the time of the false external modification the file was > 2000 lines long, but eventually I got the message. Getting a second false message is a simple task

Press continue
Ctrl+A
<backspace>
Ctrl+S
Ctrl+K
Ctrl+K

so a new false pop-up comes with the second macro execution and this seems to be fully reproducible way to get the second message although getting the first message takes arbitrary amount of macro executions.

marilmanen avatar Dec 03 '21 05:12 marilmanen

OK, good to now. I am considering chaning how we track file changes entirely. So hopefully I'll get to the bottom of this in the process.

eteran avatar Dec 06 '21 15:12 eteran

We could probably use QFilesystemwather and dispense with the polling.

On Dec 6, 2021, at 10:17 AM, Evan Teran @.***> wrote:

 OK, good to now. I am considering chaning how we track file changes entirely. So hopefully I'll get to the bottom of this in the process.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

sjtringali avatar Dec 06 '21 22:12 sjtringali

@sjtringali that is exactly the plan :-)

eteran avatar Dec 06 '21 23:12 eteran