what happens when calling KDirWatch::addDir() multiple times with the same path?

René J.V. Bertin rjvbertin at gmail.com
Sat Dec 2 20:56:12 UTC 2017


On Saturday December 02 2017 20:50:01 David Faure wrote:

>> No, why the code would be doing this:
>
>"This" what?

Your quote below this line...


>Doesn't that function know that it already loaded that directory?

No. Well, in a sense it has access to that information somewhere, but checking that isn't different from having it check if the dirwatcher already has set a watch on the directory.

>I don't know what wrapper you have in mind.

The one I showed, checking KDirWatch::contains(). I find it more elegant to write a thin wrapper around KDW (or extend KDW to support a mode without ref-counting) than query the app's internal data structure (directory representation) to see if the directory has already been loaded.

The dirwatcher can also be exported to other parts of the app's code which presumably can set or unset watches (still need to check that).

>I don't expect trouble. Why removeDir() at all, then?

With iNotify it may not be necessary if I read you correctly. Other backends used by QFileSystemWatcher have platform-dependent limitations which make it a good idea not to leave resource allocated unnecesarily.

R.


More information about the Kde-frameworks-devel mailing list