[Development] QThread usage/guidance

Tony Van Eerd tvaneerd at rim.com
Wed Oct 10 19:58:21 CEST 2012

> -----Original Message-----
> From: Giuseppe D'Angelo [mailto:dangelog at gmail.com]
> Sent: Wednesday, October 10, 2012 12:46 PM
> To: Tony Van Eerd
> Cc: Sze Howe Koh; development at qt-project.org
> Subject: Re: [Development] QThread usage/guidance
> On 10 October 2012 16:00, Tony Van Eerd <tvaneerd at rim.com> wrote:
> > I don't have any use cases, but I can't imagine the example
> recommendation
> > of
> >
> > connect(thread, SIGNAL(finished()), worker, SLOT(deleteLater()));
> >
> > working as expected unless deleteLater() happens on the same thread
> as
> > finished(), via a direct call.
> Why do you say so?

Note that I'm trying to delete the Worker object, not the QThread.
And, from the example the Worker lives on the "child" thread.

So if finished() somehow was sent from the parent thread (ie via the queue), then queue-connected to deleteLater() back to the child thread, I can imagine the child thread would be long gone, and thus the deleteLater() will never happen.

I can't imagine the child thread somehow *waiting* on the "result" of finished() on the main thread, and then seeing if it caused any slots to be queued on its child thread.  That would be a recipe for easy dead-lock, I think.


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