Hey guys,
some of you might still remember the hassle we got with the last attempt of using GIO to improve file monitoring.
So, after a long time I didn't touch the code I gave it another try and this time with a slightly different concept:
now, we use the events we get from GIO only as a hint that the file *might* have been changed. Before, we assumed that the file actually has changed when we receive such an event. Now, after we got such an event, we mark the file as changed causing the tab label to be coloured orange but nothing more. Only once the user switches to this tab or presses a key/mouse button if the tab is active, then we check the file's on-disk status using stat() to verify whether it needs to be reloaded or resaved.
So, in short, the non-GIO code checks the file's on-disk status with stat() if the configured interval timed out, the new GIO based code does the same checks but only if the file has been as changed or deleted by GIO before.
Existing problems: - the problem that the file is marked as changed when you very. very fast do edit+save cycles (existed also in the prior versions). I'm not sure whether and how this can be fixed nor whether it needs to be fixed. For me, it's really hard to reproduce for testing, I probably never would get it in real-world usage.
- when you use the GeanyVC plugin (e.g. with GIT) and revert the current file, it gets reloaded by the plugin and then it is marked as changed. When you then click in the editor widget, Geany checks the file status with stat () and notice it is not changed and so it resets the changed status and does nothing. So, this is some kind of false positive. Maybe we can workaround this. OTOH it isn't that crucial I think, once you know this can happen, it's ok I think.
- when an opened file is externally changed by 'svn revert file', it won't get recognised in Geany because we receive the 'created' event in this case but we ignore this currently. If we would not ignore it, we would get other false positives when e.g. saving a file with a different name (File->Save As). Not yet sure how to fix that.
Now it's your turn. Test the code with latest SVN please and give some feedback. To activate it, either edit src/document.c and uncomment line 51 or use one of the following commands to build Geany: CFLAGS="$CFLAGS -DUSE_GIO_FILEMON" ./configure make ...
or
CFLAGS="$CFLAGS -DUSE_GIO_FILEMON" ./waf configure ./waf build ...
Thanks, Enrico
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi,
I've compiled the GIO monitoring yesterday and noticed no problem until now. But just right now, I'm spammed with reload dialogs, I really don't know why. I opened a non-existing file from command line in order to create it in a running Geany instance, then started editing it. And now, sometimes (often) I get reload messages, but I really don't know why as it seems not to be due to a fast save-edit cycle (I can't reproduce this by edit/saving in a very short cycle), and surely not by a real external file change.
If you have any idea of what can be the cause and/or how to investigate deeper, I can try to track this, but for now I've no idea of what can be the cause.
Regards, Colomban
On Thu, 09 Jul 2009 22:34:48 +0200, Colomban wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi,
I've compiled the GIO monitoring yesterday and noticed no problem until now. But just right now, I'm spammed with reload dialogs, I really don't know why. I opened a non-existing file from command line in order to create it in a running Geany instance, then started editing it. And now, sometimes (often) I get reload messages, but I really don't know why as it seems not to be due to a fast save-edit cycle (I can't reproduce this by edit/saving in a very short cycle), and surely not by a real external file change.
If you have any idea of what can be the cause and/or how to
It's definitely related to opening non-existent files from the command line, this is one use-case I never tested :).
I'll have a deeper look later this week. Thanks for testing.
Regards, Enrico
On Tue, 14 Jul 2009 21:54:39 +0200, Enrico wrote:
On Thu, 09 Jul 2009 22:34:48 +0200, Colomban wrote:
Hi,
I've compiled the GIO monitoring yesterday and noticed no problem until now. But just right now, I'm spammed with reload dialogs, I really don't know why. I opened a non-existing file from command line in order to create it in a running Geany instance, then started editing it. And now, sometimes (often) I get reload messages, but I really don't know why as it seems not to be due to a fast save-edit cycle (I can't reproduce this by edit/saving in a very short cycle), and surely not by a real external file change.
If you have any idea of what can be the cause and/or how to
It's definitely related to opening non-existent files from the command line, this is one use-case I never tested :).
Fixed. The problem was that we don't setup file monitoring for new, non-existent files. This is correct (obviously) but once the file is saved to disk, we should start monitoring. This wasn't case but now fixed in SVN.
Regards, Enrico
On Thu, 9 Jul 2009 00:25:33 +0200 Enrico Tröger enrico.troeger@uvena.de wrote:
now, we use the events we get from GIO only as a hint that the file *might* have been changed. Before, we assumed that the file actually has changed when we receive such an event. Now, after we got such an event, we mark the file as changed causing the tab label to be coloured orange but nothing more. Only once the user switches to this tab or presses a key/mouse button if the tab is active, then we check the file's on-disk status using stat() to verify whether it needs to be reloaded or resaved.
BTW, although I don't have GIO, this seems to improve the use case for detecting changed documents when running:
svn diff >out.diff && geany out.diff
Before I would sometimes get asked twice whether to reload each time I executed that line. Now only once :)
Regards, Nick
P.S. Why not just use geanyvc? Because I like the diff tags in the sidebar.