[PyKDE] Memory leak with QDialog
Giovanni Bajo
rasky at develer.com
Tue Feb 28 08:47:24 GMT 2006
Phil Thompson <phil at riverbankcomputing.co.uk> wrote:
>> Except that this is not totally equivalent:
>> - In the C++ version, dlg is a local variable: so it gets deleted
>> when we get out of function().
>> - In the Python version, dlg is owned by self: when we get out of
>> function(), it is still referenced and won't get garbage collected. A
>> workaround to that problem is to reparent the dialog, like this:
>>
>> def function(self):
>> dlg=MyDialog(self)
>> dlg.exec_loop()
>> dlg.reparent(None, QPoint(0,0))
>>
>> The attached Python example demonstrates this.
>>
>> If there is a better solution, let me know.
>
> You don't say what versions you are using. I think this was fixed in
> v3.15 - at least I don't see any leak in current snapshots.
Yes, I can confirm it was fixed. Though QPopupMenu is exactly in the same
situation and it was not fixed: I reported this before.
Giovanni Bajo
More information about the PyQt
mailing list