[pygtk] signal_autoconnect weirdness
Damien Elmes
resolve@repose.cx
05 Feb 2002 22:14:18 +1100
Hi folks,
I've been attempting to port this little python mp3 player I'm working on to
Gtk2 and the newer pygtk/libglade stuff. I've run into some interesting
hitches, some of which were due to me not properly understanding the new API.
This one I'm confused about, though.
Basically I store callbacks in a class, and use an instance to share data. To
enable all my callbacks, I'd do something like this:
dict = {}
for key in PlaylistWindow.__dict__.keys():
val = getattr(self, key)
if isinstance(val, types.MethodType):
dict.update({key: val})
self.xml.signal_autoconnect(dict)
Which seems to work fine in the old pygtk. I've run into a weird problem with
the 1.99.7 release, though - printing the dict yields the same on both
releases, but it's as if signal_autoconnect is behaving differently. If I print
'self' as its passed to one of my callbacks now, I get:
repr(self) = <bound method PlaylistWindow.update_current of <bound
method PlaylistWindow.on_jump_to_selected_activate of <bound method
PlaylistWindow.on_select_previous_activate of <bound method
PlaylistWindow.on_refresh_activate of <bound method
PlaylistWindow.on_cue_backward_activate of <bound method
PlaylistWindow.on_select_plus_ten_activate of <unbound method
Playlist.add_hook>>>>>>>
type(self) = <type 'instance method'>
This sort of crazyness seems to cause python to segfault, too:
(gdb) bt
#0 0x40043079 in PyInstance_New () from /usr/lib/libpython2.2.so.0.0
#1 0x40067eb3 in PyTuple_SetItem () from /usr/lib/libpython2.2.so.0.0
#2 0x4004354b in PyInstance_New () from /usr/lib/libpython2.2.so.0.0
#3 0x4003c209 in PyObject_Call () from /usr/lib/libpython2.2.so.0.0
#4 0x40087ee2 in PyEval_CallObjectWithKeywords () from /usr/lib/libpython2.2.so.0.0
#5 0x4003c27f in PyObject_CallObject () from /usr/lib/libpython2.2.so.0.0
#6 0x40279cee in initgobject () from /home/resolve/garnome/lib/python2.2/site-packages/gobjectmodule.so
Have I missed something, and do I need to change my code, or does this look
like a bug?
Thanks in advance,
--
Damien Elmes
resolve@repose.cx