[Interest] void pointers

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Wed Jul 17 06:30:31 CEST 2013


On Tue, Jul 16, 2013 at 9:19 PM, Phil Hannent <phil at hannent.co.uk> wrote:

> Hi,
>
> I have a codebase that is using a C library and Qt. I have some legacy
> code where structs from the C library are stored in a Qt/C++ class using:
>
> void *userData;
>
> Is this an example where I should replace the void * with a QSharedPointer
> or a QWeakPointer?
>

The answer would depend on whether you're sharing this pointer with other
classes and/or whether your class is taking ownership of this data.

If it's for private use within your Qt/C++ class then, as other have said,
you don't need a shared ptr.

However, if you're sharing this data with others, and they can potentially
delete it, then it's a good idea to keep it as a shared ptr.

CMIIW.

HTH,
-mandeep


>
> Regards
> Phil Hannent
>
> _______________________________________________
> 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/20130717/59fe5e48/attachment.html>


More information about the Interest mailing list