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

Thiago Macieira thiago.macieira at intel.com
Fri Sep 29 22:09:41 CEST 2017


On sexta-feira, 29 de setembro de 2017 12:50:07 PDT René J. V. Bertin wrote:
> Thiago Macieira wrote:
> > We're not claiming that you have no problem. We're saying the problem is
> > probably in your own code.
> 
> It's a kind of chicken-or-egg question. I'm indeed doing something that
> triggers a problem which is clearly deep inside Qt code. What I want to
> know is whether it's acceptable/foreseeable that that problem gets
> triggered or if it shouldn't be triggered.
> 
> For now I'm going to take away the conclusion that the mutex indeed has to
> be in my code.

Even then we won't support you. QFSW, like almost all QObjects, must only be 
touched by one thread. Anything else you do is at your own risk.

> How does QFSW handle a situation in which an already watched directory is
> changed while another directory is being added? Would something else happen
> when adding directories happens on a background thread while change signals
> are connected to slots on the main thread?

The Darwin implementation has an internal mutex so that the dispatcher thread 
(I'm assuming) is able to get to the current state.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list