On dimanche 26 novembre 2017 00:19:27 CET René J.V. Bertin wrote: > Hi, > > KDirWatch is mostly rather old code, does anyone really know why it does > what it does?
"Why" is always hard, but your questions are only about "what", so that's easy, the code answers that ;) > For instance, watching a directory multiple times with KDW::addDir() results > in as many "Added already watched Entry" debug messages but I can't get my > head around the underlying goal. The goal of what? That categorized and off-by-default debug message? The goal of that is clearly debugging ;) It's a debug and not a warning, and the word already doesn't imply anything bad. > It's also not clear (as in undocumented) > whether you'd need to call KDW::removeDir() the same number of times in > order to stop watching the directory in question (I'm assuming you have > to). The code answers this, at least. When you get the debug message, it means it called (*it).addClient(instance, watchModes); which does for (Client &client : m_clients) { if (client.instance == instance) { client.count++; client.m_watchModes = watchModes; return; } } So this is reference counted. Nice, heh? > As a result I feel I need to wrap each call to KDW::addDir(foo) with a check > of KDW::contains(foo). No you don't need to do that. -- David Faure, fa...@kde.org, http://www.davidfaure.fr Working on KDE Frameworks 5