GNOME Bugzilla – Bug 692044
treeselection does not release references if treeview is destroy()ed
Last modified: 2018-01-10 20:22:02 UTC
Created attachment 233810 [details] Script showing the issue Doing: treeview.get_selection().connect("changed", mycb) treeview.destroy() Leaves a reference hanging around on mycb. This doesn't happen if destroying a gtkcontainer with a child widget that has a callback. The attached script demos it a bit better. It might be specific to using gtkbuilder. I didn't have this problem with pygtk2.
It looks like this problem was already fixed in bug 685598. Please reopen if this is not the case. Thanks. >>> import sys >>> from gi.repository import Gtk >>> >>> def fn(*args): ... print('hey') ... >>> sys.getrefcount(fn) 2 >>> tv = Gtk.TreeView() >>> tv.get_selection().connect('changed', fn) >>> sys.getrefcount(fn) 3 >>> tv.destroy() >>> sys.getrefcount(fn) 2 *** This bug has been marked as a duplicate of bug 685598 ***
Hi Simon, thanks for the quick response. However I installed pygobject-3.7.4 from Fedora, and the issue still reproduces with my script. The __del__ handler is not invoked for the second set of output.
It seems like the builder object is holding a reference to the selection object and there is a circular reference with the Python handler/mygobj and the builder. Explicitly setting builder to None makes this go away. What is unclear to me at this point is actually how the first example is working :) g2.builder = None
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/42.