On Wed, 07 Sep 2011 12:54:27 +0100 Peter Clifton <pcjc2@xxxxxxxxx> wrote: > On Wed, 2011-09-07 at 10:42 +0200, Kovacs Levente wrote: > > Each time I save my layout, a message appears: "layout changed. Do you > > want to load it?" or something like that. > > > > Brrrrrr.... well of couse it changed! I saved it! :-) Ok, I know it is a good > > feature... > > Yes - it turns out that my code here is very buggy. I'm working on a > fix, but it turns out that there are some quite subtle things going on. > > Disconnecting the file-watch before save, then re-connecting it after > doesn't even work (sometimes), as for some reason - after having used > the GTK file-selector dialog to pick a file-name, the file-watch code > will report events from changes on disk BEFORE you hooked it up. How about this for a solution: 1. When saving to disk, don't disconnect/reconnect the file watch, just leave it connected. However, ignore any file modification events until the save is completed. Set a flag: ignore_changes := True 2. Immediately after the save is completed, read the modification time on the file from disk. Store this time: save_time := file.mtime 3. Set ignore_changes := False to resume processing file modification events. The modification event handler should, however, ignore any modification event if the file modification time is equal to the previously captured save_time. Regards, Colin
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ geda-user mailing list geda-user@xxxxxxxxxxxxxx http://www.seul.org/cgi-bin/mailman/listinfo/geda-user