[Geany-devel] GIO-based file monitoring revisited

Enrico Tröger enrico.troeger at xxxxx
Wed Jul 8 22:25:33 UTC 2009

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
To activate it, either edit src/document.c and uncomment line 51 or use
one of the following commands to build Geany:


./waf build


Get my GPG key from http://www.uvena.de/pub.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20090709/3e92bab0/attachment.pgp>

More information about the Devel mailing list