After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 692044 - treeselection does not release references if treeview is destroy()ed
treeselection does not release references if treeview is destroy()ed
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks: 693111
 
 
Reported: 2013-01-18 23:18 UTC by Cole Robinson
Modified: 2018-01-10 20:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Script showing the issue (1.75 KB, text/x-python)
2013-01-18 23:18 UTC, Cole Robinson
Details

Description Cole Robinson 2013-01-18 23:18:59 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.
Comment 1 Simon Feltman 2013-01-19 10:50:36 UTC
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 ***
Comment 2 Cole Robinson 2013-01-19 19:16:11 UTC
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.
Comment 3 Simon Feltman 2013-04-19 10:54:30 UTC
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
Comment 4 GNOME Infrastructure Team 2018-01-10 20:22:02 UTC
-- 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.