Re: python classes and signal connects
- From: Simon Feltman <s feltman gmail com>
- To: Thomas Bechtold <thomasbechtold jpberlin de>
- Cc: python-hackers-list gnome org
- Subject: Re: python classes and signal connects
- Date: Fri, 5 Oct 2012 19:32:55 -0700
Hi Thomas,
I was able to verify the general callback closure mechanism within
pygobject and used by Gtk.Builder.connect_signals is leaking
references. See:
https://bugzilla.gnome.org/show_bug.cgi?id=685598
Also attached to this ticket is a unittest showing how to verify
reference counts in a unittest context which might be of use.
What is actually leaking in this case is the dictionary holding the
callback, which in turn keeps the callback around.
-Simon
On Thu, Oct 4, 2012 at 9:35 AM, Thomas Bechtold
<thomasbechtold jpberlin de> wrote:
> Hi Simon,
>
> thanks for the detailed answer! See comments bellow.
>
> On Mi, 2012-10-03 at 01:17 -0700, Simon Feltman wrote:
>> 1) Don't rely on __del__ for cleanup, __del__ should generally be
>> avoided as it doesn't work like a destructor in most languages, add an
>> explicit method to cleanup the AddressInfo instance, clear out any
>> held widgets by setting them to None, also issue the dbus disconnect
>> within this and even disconnect signals if possible.
>
> Disconnecting signals produces segfaults. See
> https://bugzilla.gnome.org/show_bug.cgi?id=685387 .
>
> Setting the Widget to None works fine in the simple example. In d-feet,
> I try to use GtkBuilder (with Glade) when possible. So attached is
> another example (button-signal-gtkbuilder.py) where the solution "set
> all Widgets to None" does no longer work. The example loads the widgets
> from an ui xml definition and connects the signals with
> gtk_builder_connect_signals().
> The instances are never collected by python's gc.
>
> Cheers,
>
> Tom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]