[Development] QThread::finished() race → fixing QThread

Olivier Goffart olivier at woboq.com
Thu Nov 3 15:57:57 CET 2011


On Thursday 03 November 2011 15:56:20 Thiago Macieira wrote:
> On Thursday, 3 de November de 2011 14:36:09 Olivier Goffart wrote:
> > Now that you mention it, this is a regression against Qt 4.7,
> > (isRunning and isFinished used to lock)
> > hence the patch: http://codereview.qt-project.org/#change,8063
> > (that should be applied to Qt 4.8 please)
> > 
> > 
> > That is not related to the order in which  finished() is emit.
> 
> Suppose my code does:
> 
> void slotConnectedToFinished()
> {
>     if (thread.isRunning())
>         thread.wait();
>     thread.start();
> }
> 
> With this change, we're sure that isRunning will always return false, even
> if the thread is still running but performing cleanups. Will the thread be
> started again?

Yes. the thread will start again.

But QThread::start will block until the cleanup is completed.



More information about the Development mailing list