qt-interest@trolltech.com
[Top] [All Lists]

Re: [Qt-interest] Question regarding QThread object affinity

Subject: Re: [Qt-interest] Question regarding QThread object affinity
From: Thiago Macieira
Date: Mon, 08 Jun 2009 21:07:41 +0200
Patric wrote:
>Hello,
>I have a question regarding threads.
>Let's assume we have a A. In that class, we have instance of class B as
> a member. We also have a QThread - class C. The class B member is not a
> pointer.
>What if I call "member_B.moveToThread()", how will the object member_B
> be deleted ? Usually, it'll be deleted when the object_A is destroyed.
> But now it's moved to another thread, who is responsible for it's
> deletion ?

If it's not a pointer, it's deleted when the scope is deleted: that is, 
when object_A is destroyed.

And since it's been moved to another thread, you cannot delete it there. 
That means you MUST move it back before letting it be destroyed.

-- 
Thiago Macieira - thiago.macieira (AT) nokia.com
  Senior Product Manager - Nokia, Qt Software
      Sandakerveien 116, NO-0402 Oslo, Norway
_______________________________________________
Qt-interest mailing list
Qt-interest@xxxxxxxxxxxxx
http://lists.trolltech.com/mailman/listinfo/qt-interest
<Prev in Thread] Current Thread [Next in Thread>