[Qt-interest] Question regarding QThread object affinity

Arnold Krille arnold at arnoldarts.de
Tue Jun 9 09:51:50 CEST 2009


Hi,

On Tuesday 09 June 2009 00:15:41 you wrote:
> I see. Thank you very much for your answer,
> >But really the C.run() would be responsible for deleting the object before
> >the end of the thread.
> but how the C.run() method will be able to delete the object_B ?
> object_B, in our example, is member of class A and class C have no idea
> that class A exists, if you know what I mean.

Yes, that is exactly the problem. B will simply become unreferenced when C 
stops. That is if A doesn't hold a reference. BUT: If A holds a reference (and 
will therefor delete the object when it goes out of scope) you are in much 
deeper trouble, because then you might kill B while it is still running in C's 
context.

BTW: I created a template to run a given object in its own thread and also 
delete it after the event-loop finished. Interested?

Arnold

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090609/8129f167/attachment.bin 


More information about the Qt-interest-old mailing list