[Development] Should QFileSystemWatcher be thread-safe? (Qt 5.8.0)

Milian Wolff milian.wolff at kdab.com
Fri Sep 29 14:27:37 CEST 2017


On Freitag, 29. September 2017 11:35:40 CEST René J.V. Bertin wrote:
> Hi,
> 
> I've been running into issues using adding and removing entries from QFSW in
> concurrent threads. This is in KDevelop while adding all directories of
> multiple projects (source trees) to a single QFSW instance per project. The
> app is somewhat complex so I think but am not entirely certain that the
> source trees are read on a single background thread; if I'm correct each
> QFSW instance is fed from a single thread only. (The QFSW instances are
> created and "slotted" on the main thread.)
> 
> The issues range from more or less severe lock-ups on Mac (the hard lock-ups
> occur in the FSEvents backend) to double-free crashes on Linux. I can only
> avoid them by using a single mutex that ensures that only 1 thread can use
> the class at a time.
> 
> The QFSW documentation only mentions the class is reentrant. Is QFSW
> supposed to be thread-safe (at least at the class level), on all platforms?
> Or do we have to provide our own protection mechanisms if we want to use
> the class this way?

Please Rene, before you waste more time by getting yet more people involved. 
Build a MWE, i.e. a trivial single-file Qt application that exhibits the 
behavior you are supposedly seeing. Then when you think you are sure what is 
going on we can talk. Don't put up open hypotheses on random channels - it's 
really draining everyones energy for no good gain. And don't come again with 
the "I don't have time" - it's less time to create a MWE than to write dozens 
of mails that then have no outcome.

-- 
Milian Wolff | milian.wolff at kdab.com | Senior Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts





More information about the Development mailing list