[texworks] external read-access causes TeXWorks to revert open file to old version

Stefan Müller warrence.stm at gmx.de
Mon Nov 1 18:24:30 CET 2010



On 28.10.2010 20:13, Stefan Löffler wrote:
> Hi,
>
> Am 2010-10-25 22:36, schrieb Stefan Müller:
>> Another thing I just recognized: In a "positive run" (i.e. where the
>> problem occurs) TW prints (beside others) the following debug messages:
>>
>> Loading: "/dir/to/my/file.tex"
>> Loading: "/dir/to/my"
>> ...
>> Loading: "/dir/to/my"
>> Changed: "/dir/to/my/file.tex"
>> Loading: "/dir/to/my/file.tex"
>
> Hm, this is strange. I guess there should be one "Changed" line
> preceding each "Loading" line when directories are involved.
>
>> Is it correct, that sometimes the directory and sometimes the file is
>> loaded?
>
> Yes, this is correct. Directories are also watched, because changes to
> the directory (rename, deletion, ...) can also (implicitly) cause
> changes to the file. This may, however, also be related to your problem
> (see below). Note that in this case, no actual load action should occur
> (which is checked below the qDebug() line you added, though).
>
> I think I mentioned this before, but your problem may be related to a
> race condition. Just as Tw detects a change (to either the directory or
> the file), further change-detection is disabled for the duration of the
> processing. So if mercurial changes the file/directory, Tw may register
> this and start its processing (doing lots of checks, remembering where
> you were in the file, etc.). Then, it loads the file. Then it tries to
> restore the previous state. And only then it re-enables the file system
> checker. So if mercurial changes the file twice for some reason (or
> changes the directory first possibly with the last committed version of
> the file and then replaces the file), Tw may pick up the wrong version.
> To verify this, could you put the following line just after the `[1094]
> qDebug()<<  "Changed:"<<  curFile;` line:
> qDebug()<<  fileModified;
> This should print the file modification time during each reload. Could
> you then compare these to the timestamp output by `ls -l --full-time` on
> the command line in both a "normal" and a "positive" run? This could
> give us an indication whether Tw picks up a different version of the file.
>
> HTH
> Stefan

I tried that additional debug line you suggested. During a "normal" run 
I don't get the "Changed" line so I don't get the timestamp either 
(other suggestions?). During a "positive" run, the debug message shows 
me the timestamp from that moment when the commit was done. But `ls -l 
--full-time` shows me exactly the time when I saved the tex file (e.g. 
30 seconds earlier).

Stefan


More information about the texworks mailing list