-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
BJörn Lindqvist schrieb:
> Hi,
>
> 2008/8/29 Herwig Hochleitner <
hhochleitner@...>:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hello!
>> My Custom DrawingArea keeps segfaulting me on being destroyed.
>> I traced it down to the following minimal example:
>>
>> [PYTHON]
>>
>> import gtk
>> import gobject
>> import gnome.ui
>>
>> class CustomDrawingArea(gtk.DrawingArea):
>> __gsignals__ = {"set-scroll-adjustments" : (gobject.SIGNAL_RUN_LAST,
>> gobject.TYPE_BOOLEAN,
>> (gobject.TYPE_OBJECT,
>> gobject.TYPE_OBJECT))}
>>
>> def __init__(self):
>> gtk.DrawingArea.__init__(self)
>> self.set_set_scroll_adjustments_signal("set-scroll-adjustments")
>>
>> def do_set_scroll_adjustments(self, hadjustment, vadjustment):
>> return False
>>
>> gobject.type_register(CustomDrawingArea)
>>
>> if __name__ == "__main__":
>> win = gtk.Window()
>> swin = gtk.ScrolledWindow()
>> da = CustomDrawingArea()
>> win.add(swin)
>> swin.add(da)
>> win.show_all()
>> gtk.main()
>>
>> [/PYTHON]
>
> There are actually two different bugs at work here.
>
>> The segfault happens when deleting the window
>
> See
http://bugzilla.gnome.org/show_bug.cgi?id=551699. When you delete
> a window, you invoke that windows destroy() method which is supposed
> to free up its references to other widgets. Except that it often
> doesn't work because many widgets implement the destroy/finalize
> scheme wrongly. Others may disagree, but I think it is best to always
> terminate your applications using sys.exit(), that way you don't have
> to deal with all the problems in gtk's object destruction system.
That clarifies things somewhat. I saw that behavior on several gtk apps
and therefore wouldn't have cared that much. But the problem was that my
widget gets reconstructed everytime the user changes the data.
>
>> or removing the custom widget from the scrolled window (in my
>> application this happens dynamically).
>
> I think this happens because your set-scroll-adjustments signal
> prototype is wrong. It should return None, not a bool. Like this:
>
> __gsignals__ = {
> "set-scroll-adjustments" : (gobject.SIGNAL_RUN_LAST,
> bool,
> (gtk.Adjustment, gtk.Adjustment))}
>
> Gtk isn't smart enough to check that your signal prototype is correct
> before calling it.
I see. I was mislead on that because gtk.Widget.set_scroll_adjustments()
returns a boolean.
Everything works now, thanks a lot.
I suppose it would be possible to check the correctnes of signal
overrides in gobject, wouldn't it?
regards
Herwig Hochleitner
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla -
http://enigmail.mozdev.orgiD8DBQFIzAlI2yN0WRIYfpERAt+sAKCjDyOw6ldAYNtpFqhybCpRcQ9gOQCfXHDy
TzKgpWBNzIapgi5CF4vEcmg=
=4lmK
-----END PGP SIGNATURE-----
_______________________________________________
pygtk mailing list
pygtk@...
http://www.daa.com.au/mailman/listinfo/pygtkRead the PyGTK FAQ:
http://www.async.com.br/faq/pygtk/