[Interest] Proper use of SharedPointer/WeakPointer

Thiago Macieira thiago at kde.org
Thu Feb 23 16:49:23 CET 2012


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120223/930ec21b/attachment.sig>


More information about the Interest mailing list