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

Stefan Müller warrence.stm at gmx.de
Wed Sep 22 16:43:11 CEST 2010


first: thank you very much for your effort.

Am Mittwoch 22 September 2010, 15:35:18 schrieb Stefan Löffler:
>  Hi,
> I did some quick tests here (Ubuntu, r670) and didn't experience
> problems so far. Since I'm not familiar with hgtk, here's what I did:
> 1) Create an empty local folder
> 2) Initialize repository by `hgtk init`
> 3) Create a file test.tex and add it by `hgtk add`
> 4) Made some changes to test.tex without saving
> 5) Commit by `hgtk commit`
> 6) Switch back to Tw
> 7) Save changes from before
> 8) repeat from 4

That's what I did, too. Unfortunately I was not able to reproduce with a new 
document, maybe it has something to do with its size .

> I also tried modifying and commiting another file separately.
> Please advise if you did something different (e.g., if you work with
> non-local files/repositories/network file systems/several branches at
> once).

It happens with a local repository.

> Note that Tw should never reload a file that is marked as modified
> (e.g., with an asterisk in the title bar) without confirmation of the
> user (a dialog pops up in case Tw detects that the file was modified on
> the harddisk).

I got this confirmation once and therefore was able to detect the error. I 
don't know what was different.

> For files that are not modified (since the last time they
> were saved), Tw reloads them automatically if they change on the hard
> disk. So if this mechanism is working as expected, the file would be
> reverted back to its earlier form somewhere else.
> Does a similar issue occur with other text editors?

It did not occur with other editors. Although I use other editors only very 
seldom, so that may be coincidental.

> Or does the problem
> persist if you close Tw before and reopen it after the commit?

If I close Tw before and open it again after the commit I get the right 
version, because tw only "displays" the old version. It is only on harddisk if 
I save the "displayed" version manually again after the commit.

> Unfortunately, since I can't reproduce the problem myself, I can't offer
> much more help than this speculation.
> BTW: The most current version is r671. Experimental Windows builds are
> available at
> http://web.student.tuwien.ac.at/~e0325258/projects/c/texworks/. I don't
> know of any such Fedora builds, but on Linux it's fairly easy to build
> Tw (see http://code.google.com/p/texworks/wiki/Building; note, though,
> that the Qt devel files are probably quite large).
> Stefan

I built the r670 version from svn-trunk without problems. I'll try with that 
one and see if it happens again, although you said in the other mail it 
possible wouldn't change anything.

> Anyway, if you build Tw yourself, you could add the following to lines
> (linenumber where to add in brackets) to get some debugging information:
> [959] qDebug() << "Loading:" << fileName;
> [1094] qDebug() << "Changed:" << curFile;
> This should print the filenames Tw loads, and whenever it detects a
> change to the filename on the harddisk.

I'll try again with this lines and see if something interesting happens.

> >> This part of your original posting makes me think that it is possibly
> >> a caching issue of commits from RAM to your hardrive.
> >> 
> >> " most of the times TeXWorks restores an version of the open file
> >> which is older than the saved document"
> > 
> > You may be right. I can't think how TeXWorks could possibly restore an
> > old version of the  document. Is TeXWorks keeping automatic backups
> > somewhere? (Like Word and OpenOffice do, to restore a file if they
> > crash)
> No, Tw shouldn't be keeping backups. However, I don't know the internals
> of mercurial. Maybe it synchronizes your working tree somehow when you
> commit (if it applies first the old and then the new revision, this
> could cause a race condition where Tw detects the first change, loads
> the file, and before the file system watcher resumes the second change
> occurs; this is just a shot in the very dark, though).

Personally, I don't think that Mercurial does something with the files that 
could cause Tw to reload the files or something, it should be read-only. But of 
course that's a possiblity. I'll check with the Mercurial users/devs if 
nothing else helps.

Thanks alot for your ideas, i'll report if I get something new.

Best regards,

More information about the texworks mailing list