[PyKDE] Properly deleting objects from a QWidgetStack

Jacob M. Burbach stolenID at cfl.rr.com
Sat Jul 26 22:26:01 BST 2003


On Saturday 26 July 2003 03:22 pm, Jacob M. Burbach wrote:
> What is the proper way to remove and destroy an object from a QWidgetStack?
>
> I tried:
> 	object = widgetStack.widget( objectId )
> 	widgetStack.removeWidget( object )
> 	del object
>
> However it doesn't seem to call the destructor of that object, causing a
> memory leak. What is the proper way to do this to make sure the object
> really gets destroyed?
>
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Update, after doing a quick check, I see I have to call 
QWidgetStack.removeChild to actually decrease the reference count
	
Example:
	object = widgetStack.widget( objectId )
  	widgetStack.removeWidget( object )
	widgerStack.removeChild(object)
	print sys.getrefcount(object)
 	del object

Which says it has 2 references, one would be the object variable, so 
apparently I have an extra reference laying around somewhere...




More information about the PyQt mailing list