[Interest] QFileSystemWatcher and kate

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Mon Sep 4 19:59:34 CEST 2017


Am 04.09.2017 um 02:17 schrieb Thiago Macieira:
> On Sunday, 3 September 2017 05:21:26 -03 Christian Ehrlicher wrote:
>> Hi,
>>
>> I stumbled across a problem with QFileSystemWatcher on Linux. It looks
>> like the inotify implementation does not honor a file replace action as
>> expected.
>> I'm adding a file with addPath() to watch for changes. But after I edit
>> the file with kate (or any other editor which saves the file in a temp
>> file and then renaming it to correct name), the QFileSystemWatcher does
>> no longer watch for modifications...
>> Looking in the bug tracker I also found a bug which describes the
>> problem:
>> https://bugreports.qt.io/browse/QTBUG-19350?jql=text%20~%20%22qfilesystemwat
>> cher%22 So it looks like this bug exists since inotify support was added but
>> the bug report was closed because it was not reproducible (maybe not tested
>> with inotify).
>> Therefore my question - how to reopen this bug or should I file a new one?
> Strictly speaking, the behaviour you're seeing is the correct one: the file you
> were watching was not modified. It was deleted. The new contents do not belong
> to this file, but to another. If you were using tail -f to follow this file you
> wouldn't see anything -- you need -F.
>
> So to fix this issue (the strictly correct behaviour is not the expected one),
> we need to add some other mechanism, like tail's flag above. That's because
> we'll need more resources, as we need to check the directory for change.
I did some tests. The windows implementation works as I (as a user of 
QFileSystemWatcher) would have expected it. A copy/rename of a file does 
not trigger an unwatch of the file.
Inotify by itself does not provide such a behavior but maybe checking 
for IN_DELETE_SELF/IN_IGNORED and re-adding the file could be an option?
At least the different behavior of the windows and inotify backend 
should be documented somewhere...

Christian



More information about the Interest mailing list