[Interest] Proper use of SharedPointer/WeakPointer

Jason H scorp1us at yahoo.com
Thu Feb 23 17:29:22 CET 2012


Thanks everyone! This would have taken me ages to figure out. #4 it is.



________________________________
 From: Thiago Macieira <thiago at kde.org>
To: interest at qt-project.org 
Sent: Thursday, February 23, 2012 10:49 AM
Subject: Re: [Interest] Proper use of SharedPointer/WeakPointer
 
On quinta-feira, 23 de fevereiro de 2012 06.40.29, Jason H wrote:
> Hrm, my objects do have parents, and when the parent goes, the children need
> to go too. How is that resolved?

It isn't.

You must resolve this on your own. Suggestions:

1) don't set a parent
2) don't put them in a QSharedPointer
3) unset the parent before the last reference is dropped
4) create the QSharedPointer with a no-op custom deleter (i.e., don't delete)

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120223/596df6dd/attachment.html>


More information about the Interest mailing list