[Development] QThread usage/guidance
Olivier Goffart
olivier at woboq.com
Fri Oct 5 16:54:18 CEST 2012
On Friday 05 October 2012 14:31:51 Tony Van Eerd wrote:
> What was the final resolution (if any) of the email thread
> "QThread::finished() race → fixing QThread"
> http://lists.qt-project.org/pipermail/development/2011-November/000284.html
>
>
> In particular as seen in
> http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-
> the-full-explanation/
>
> worker->moveToThread(thread);
> connect(worker, SIGNAL(error(QString)), this,
> SLOT(errorString(QString))); connect(thread, SIGNAL(started()), worker,
> SLOT(process())); connect(worker, SIGNAL(finished()), thread,
> SLOT(quit())); connect(worker, SIGNAL(finished()), worker,
> SLOT(deleteLater())); connect(thread, SIGNAL(finished()), thread,
> SLOT(deleteLater()));
>
> Is there a race where the worker deleteLater() doesn't happen due to the
> thread having already finished?
There used to be that race. But since Qt 4.8, the deleteLater is handled
separatly specially to allow this usage (commit 0c643b179)
So I see no races.
--
Olivier
Woboq - Qt services and support - http://woboq.com
More information about the Development
mailing list