[Development] QThread usage/guidance

Tony Van Eerd tvaneerd at rim.com
Fri Oct 5 17:24:40 CEST 2012


So that is the 'recommended' style then?


> -----Original Message-----
> From: Olivier Goffart [mailto:olivier at woboq.com]
> Sent: Friday, October 05, 2012 10:54 AM
> To: development at qt-project.org
> Cc: Tony Van Eerd
> Subject: Re: [Development] QThread usage/guidance
> 
> 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
> 


---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.


More information about the Development mailing list