[UFO-devel] memory leak3: icons/images
Status: Beta
Brought to you by:
schmidtjf
From: Andreas B. <b_...@gm...> - 2005-08-16 14:29:04
|
Hi suppose the following: ufo::UButton* button = new ufo::UButton(...); ... ufo::UImage* image = new ufo::UGL_Image(...); // load an image button->setIcon(new ufo::UImageIcon(image)); ... parentOfButton->removeAll(); What I would expect here: the removeAll() call removes the button (which actually works) which in turn removes the icon (which works, too) and therefore the image. However what actually happens: when ufo::UGL_Image::paint() is called, it calls ufo::UGL_Image::ensureImage(). Once this is called the very first time, it creates the texture and calls ufo::UDisplay::addVolatileData(this). ufo::UAbstractDisplay::addVolatileData() however, calls ufo::UGL_Image::reference(). Therefore, when the ufo::UImageIcon object unreference()s all it's pointers, the reference count of the image will still be 1 and the image won't ever be deleted. ufo::UAbstractDisplay::removeVolatileData() is never called, as this would be done by the d'tor of ufo::UGL_Image. In addition: the d'tor of ufo::UAbstractDisplay does not 1. delete remaining objects in m_volatileData 2. does not emit a warning/error about remaining objects. Very bad for debugging. Wow, this one has really been difficult to find. CU Andi |