Wrong QSharedDataPointer<Private> in kdelibs?

Matthias Kretz kretz at kde.org
Wed Apr 23 20:44:57 BST 2008


On Wednesday 23 April 2008, Christian Ehrlicher wrote:
> Hi,
>
> Everywhere in kdelibs I see such constructs:
>
> QSharedDataPointer<Private> d;
>
> KFoo::KFoo() : d(new Private())
> {}
>
> KFoo::~KFoo()
> {}
>
>
> I'm missing 'delete d' in dtor - or do I miss something here?

QSharedDataPointer will delete the object when the reference count goes to 
0. 'delete d' also doesn't make that much sense as d is not a pointer (though 
it has a cast operator, but if delete is called on that you'd produce a 
dangling pointer and at least a double delete).

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080423/ff1c5e60/attachment.sig>


More information about the kde-core-devel mailing list