Resolve circular reference

Stefan Behnel stefan_ml at behnel.de
Mon Jan 10 13:18:02 EST 2011


moerchendiser2k3, 10.01.2011 18:55:
>> If you can tell us why it's so important that the object be destroyed
>> at that given time, even while a reference to it exists, maybe we can
>> give you better suggestions.
>
> Thanks for your answer! In my case the types A and B (in my example
> above)
> are a dialog and a dialog widget. At a special time I have to close
> and
> destroy all dialogs but this does not happen because the widget keeps
> the dialog alive. I have the reference to the dialog
> but after I closed the dialogs I also would like to destroy them
> because they have to free some special ressources.

Objects within a reference cycle will eventually get cleaned up, just not 
right away and not in a predictable order.

If you need immediate cleanup, you should destroy the reference cycle 
yourself, e.g. by removing the widgets from the dialog when closing it.

Stefan




More information about the Python-list mailing list