GNOME Bugzilla – Bug 672864
Can not listen to signals in subclassed subclasses
Last modified: 2012-06-01 09:59:49 UTC
The following worked in the static GTK+ 2 bindings, only the 'do_clicked' method of SubButton is called: {{{ import gtk import gobject def _destroy_cb(widget, data=None): gtk.main_quit() class Button(gtk.Button): __gtype_name__ = 'SugarButton' def __init__(self, **kwargs): gtk.Button.__init__(self, **kwargs) def do_clicked(self): print 'Button clicked' class SubButton(Button): __gtype_name__ = 'SugarSubButton' def __init__(self, **kwargs): Button.__init__(self, **kwargs) def do_clicked(self): print 'SubButton clicked' window = gtk.Window() window.set_default_size(450, 450) window.connect("destroy", _destroy_cb) b = SubButton(label='hallo') window.add(b) b.show() window.show() gtk.main() }}} In GTK+3 with the dynamic bindings, the 'do_clicked' method of Button gets called not the overriden one of SubButton. {{{ from gi.repository import Gtk def _destroy_cb(widget, data=None): Gtk.main_quit() class Button(Gtk.Button): __gtype_name__ = 'SugarButton' def __init__(self, **kwargs): Gtk.Button.__init__(self, **kwargs) def do_clicked(self): print 'Button clicked' class SubButton(Button): __gtype_name__ = 'SugarSubButton' def __init__(self, **kwargs): Button.__init__(self, **kwargs) def do_clicked(self): print 'SubButton clicked' window = Gtk.Window() window.set_default_size(450, 450) window.connect("destroy", _destroy_cb) b = SubButton(label='hallo') window.add(b) b.show() window.show() Gtk.main() }}}
Abother request of the same issue: http://mail.gnome.org/archives/python-hackers-list/2011-December/msg00013.html
Confirmed with 3.2.
Created attachment 214001 [details] [review] fix vfunc lookup with intermediate subclasses This patch fixes the issue, it uses __mro__ to find out the VFuncInfo, as the corresponding attribute is shadowed with the unbounded method in the intermediate python subclass
Thanks Carlos for the patch! Applied here to master and it does reproduce the desired result. The test case from above passes fine.
Thanks Carlos! I created a test case for this, and committed it with your patch: http://git.gnome.org/browse/pygobject/commit/?id=07a08b49aae83a297e2f91240448314e4663f724
Thanks Martin, you rock! /me can make another cross on his bug list...