Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
greenmr
Posts: 862
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Does Option::setImage() transfer ownership?

Does anyone know categorically if Option::setImage() transfers ownership of the image to the Option? Cascades documentation doesn't mention it either way, but most Cascades classes assume ownership when another object is added to them.

 

I've become fanatical lately about ensuring that all instantiated descendents of QObject have a parent.



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Please use plain text.
Developer
Zmey
Posts: 1,507
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Does Option::setImage() transfer ownership?

Hi,

As it takes the Image by reference (Image &), I don't think it transfers the ownership. Possibly it copies the image or image handle internally, but you still own the Qt object.

But you can verify this easily by printing image->parent() before and after the call to setImage.

Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
greenmr
Posts: 862
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Does Option::setImage() transfer ownership?

I think I answered my own question. Image doesn't seem to have a parent as there is no Image::setParent() function. From what I can make out, Images are ALWAYS duplicated when assigned and the copy is owned by the assignee, although in some case it is a lazy copy, which is to say that the copy is a pointer to the original Image until one or both of the copies are modified, at which time they part ways and a real copy is made.



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Please use plain text.