PDA

View Full Version : QIcon::QIcon(), QPixmap::setAlphaChannel(), and input parameter ownership



mule
31st May 2006, 21:11
Does QIcon::QIcon( const QPixmap & pixmap ) take ownership of its input parameter, pixmap?
Does QPixmap::setAlphaChannel( const QPixmap & alphaChannel ) take ownership of its input parameter, alphaChannel?

In other words, for ...


QPixmap * pPixmap;
QBitmap * pBitmap;
QPainter P;
QIcon * pIcon;

pPixmap = <pointer to image previously read in>;

pBitmap = new QBitmap( * pPixmap );

P.begin( (QPaintDevice *) pBitmap );
// painting here
P.end();

pPixmap->setAlphaChannel( * pBitmap );

pIcon = new QIcon( * pPixmap );

...

delete pIcon;

... does the delete statement also delete the Pixmap and/or the Bitmap?

jacek
31st May 2006, 21:31
Does QIcon::QIcon( const QPixmap & pixmap ) take ownership of its input parameter, pixmap?
Does QPixmap::setAlphaChannel( const QPixmap & alphaChannel ) take ownership of its input parameter, alphaChannel?
No they don't. Both of these parameters are references to a constant object, which means that those methods can't destruct these objects (not mentioning making any other changes in their internal state).


In other words, for ... does the delete statement also delete the Pixmap and/or the Bitmap?
No, it does not delete those objects. QIcon doesn't even know that pPixmap is a pointer.

mule
31st May 2006, 21:52
Thank you very much, jacek.