GNOME Bugzilla – Bug 711173
TreeViewColumn set_cell_data_func doesn't accept None as callback anymore
Last modified: 2013-11-04 11:42:55 UTC
the git master version of pygobject raises an exception when Gtk.TreeViewColumn.set_cell_data_func(Gtk.CellRendererText(), None, None) is used. We are using code to workaround a memory leak problem that is present in old versions (it was just recently fixed in pygobject) and we would like to keep supporting older pygobject versions as well. As a reproducer, these four lines show the problem: ############################################# from gi.repository import Gtk col = Gtk.TreeViewColumn("Name") txt = Gtk.CellRendererText() col.set_cell_data_func(txt, None, None) ############################################# and this is the error I get: Traceback (most recent call last):
+ Trace 232686
col.set_cell_data_func(txt, None, None)
super(TreeViewColumn, self).set_cell_data_func(cell_renderer, func, func_data)
It seems that userdata is not correctly checked, as in the code it is None.
To expand a bit, the above code works fine on 3.10, but fails on 3.11. So this is a regression. As Guiseppe says, we use this code to unregister unused cell_data callbacks in virt-manager to help avoid the memory leak in bug 709397 which isn't fixed in all distros yet.
The following fix has been pushed: 79aea26 Remove overzealous argument checking for callback userdata The argument check here has always stood out as a bit odd to me. So I've removed it to fix this bug and simplify things.
Created attachment 258914 [details] [review] Remove overzealous argument checking for callback userdata Remove check which ensures userdata is None if the callback is None. This check would need to become more complicated with recent versions of PyGObject where userdata can be variable (would also need to check against a tuple containing None). Instead of adding more complex checking, simply remove the checking as it is unnecessary to begin with.