description: ============ exceptions throwing/catching is the high level error recovery mechanism of perl. however, dieing in a gtk callback now results in unexpected behaviour (that is from a perl programmer viewpoint, of course gtk+ as being developed in c is not supposed to support them):
===========================================================================================> GLib-GObject-ERROR **: file gsignal.c: line 646 (emission_pop): should not be reached > aborting... > zsh: abort logdrake > ===========================================================================================>
as for example, see gtk2-perl/misc-examples/exception-trapping.pl from old inline tree. short answer to this bug may be "do not do that" but: - when you've some quite a big code base, it's sometimes easier to do error managment like this and anyway, - this is one of perl way of doing it, and it really save some code and/or make code saner. explanation: ============ the problem (as explained by guillaume) is that: - gtk+, as being x11 client side, performs an active loop on x events, react to them, interpret them in terms of gtk events that need calling gtk callbacks - there's some kind of gtk_main() call stack - if we got a perl exception, we interrupt normal gtk execution and bypass normal gtk return from callback - once we catch the exception from perl and try to perform more, we'll put glib/gtk+ in trouble as soon as we try to resume normal gtk+ operation old gtk-perl and gtk2-perl recovery systems: ============================================ guillaume implemented some recovery system in gtk2-perl/Gtk2/src/Gtk2.c and in gtk2-perl/Gtk2/src/GClosure.c, that is: - each call to gtk_main result in incrementing a main call counter - we run perl-gtk callback with G_EVAL - if we catch an exception: o if we already cautgh another exception, print a "sorry folks" message o else we save the exception that need to be croaked again and we run gtk_main_quit o once c gtk_main had exited, perl gtk_main croak the pending exception but this mechanism was not keeped when switching to inline to xs (due to saner/better design of new tree). old perl-GTK (that is gtk+-1.0/1.2 perl binding) also has such a mechanism (die in callback did worked). porting old recovery system: ============================ Compare GClosure.c from inline tree to Glib/GClosure.xs from new tree: naive merging of guillaume recovery system may look like this regarding glib:
Attachment:
marshall.diff
Description: Text Data
however, note that: - xs tree sanely separate glib from gtk, thus: o we cannot call gtk_main_quit from there o we cannot easily share variables between Glib.so and Gtk2.so (so that perl's gtk_main know there's an exception to croak) - i've reach my limited knowledge of xs, so we need someone more intelligent than me to restore old perl-GTK-0.7xx and inline perl-GTK2 binding behaviour regarding perl exceptions throwed from gtk callbacks :-(