Re: Build problem Gtk2-1.037



Thierry Vignaud <tvignaud mandrakesoft com> writes:

- Given the above, you can very easily install an exception handler
that kills the main loop and cleans up properly.

this is actually what do ugtk2 package :-)

we just put the needed infrastructure in perl-glib to be able to do
that: install_exception_handler()/remove_exception_handler() is still
availlable and still works smoothly!

we just enable either to use the classic "treat errors where it
happens" way or the exceptions throwing/trapping way

for the record the glib/gtk2 binding patches:
--- ./GClosure.xs.ex    2003-11-17 02:37:26.000000000 +0100
+++ ./GClosure.xs       2004-01-10 00:46:38.000000000 +0100
@@ -592,6 +592,28 @@
        LEAVE;
 }
 
+void (*gtk2_perl_trap_exceptions_handler) (void);
+
+glib_perl_set_execept_handler (void (*exceptions_handler) (void))
+{
+     gtk2_perl_trap_exceptions_handler = exceptions_handler;
+}
+
+SV* gtk2_perl_trap_exceptions_save_errsv   = NULL;
+
+SV*
+glib_perl_get_execept_errsv ()
+{
+     return gtk2_perl_trap_exceptions_save_errsv;
+}
+
+void
+glib_perl_set_execept_errsv (SV* exception)
+{
+     gtk2_perl_trap_exceptions_save_errsv = exception;
+}
+
+
 =item void gperl_run_exception_handlers (void)
 
 Invoke whatever exception handlers are installed.  You will need this if
@@ -619,6 +641,14 @@
 
        ++in_exception_handler;
 
+       if (gtk2_perl_trap_exceptions_handler) {
+                       n_run++;
+                       --in_exception_handler;
+                       G_UNLOCK (exception_handlers);
+                       gtk2_perl_trap_exceptions_save_errsv = newSVsv(ERRSV);
+               (*gtk2_perl_trap_exceptions_handler)();
+                       return;
+       } else {
        /* call any registered handlers */
        for (i = exception_handlers ; i != NULL ; /* in loop */) {
                ExceptionHandler * h = (ExceptionHandler *) i->data;
@@ -646,6 +679,7 @@
                g_value_unset (&return_value);
                ++n_run;
        }
+       }
 
        --in_exception_handler;
 
--- ./gperl_marshal.h.tv        2004-01-14 17:17:58.000000000 +0100
+++ ./gperl_marshal.h   2004-01-14 17:19:14.000000000 +0100
@@ -176,7 +176,6 @@
        SPAGAIN;                                                \
        if (SvTRUE (ERRSV)) {                                   \
                gperl_run_exception_handlers ();                \
-               SvSetSV (ERRSV, save_errsv);                    \
                FREETMPS;                                       \
                LEAVE;                                          \
                return;                                         \
--- ./xs/Gtk2.xs.except 2004-01-09 20:27:59.000000000 +0000
+++ ./xs/Gtk2.xs        2004-01-09 23:39:45.631164584 +0000
@@ -247,9 +247,26 @@
  ##void           gtk_main_do_event       (GdkEvent           *event);
 
 void
+gtk_croak_execeptions (class)
+    CODE:
+       glib_perl_set_execept_handler(&gtk_main_quit);
+
+void
 gtk_main (class)
     C_ARGS:
        /*void*/
+    PREINIT:
+       SV * exception;
+   CODE:
+       gtk_main();
+       exception = glib_perl_get_execept_errsv();
+       if (exception) {
+              sv_setsv(ERRSV, exception);
+              SvREFCNT_dec(exception);
+              glib_perl_set_execept_errsv(NULL);
+              croak(Nullch);
+       }
+
 
 guint
 gtk_main_level (class)

and the ugtk2 relevant bits:

====================================================================================>
unless ($::no_ugtk_init) {                                                         >
    !check_for_xserver() and die "Cannot be run in console mode.\n";               >
    $::one_message_has_been_translated and                                         >
       warn("N() was called from $::one_message_has_been_translated                >
BEFORE gtk2 initialisation, replace it with a N_() AND a translate()               >
    later.\n"), c::_exit(1);                                                       >
    Gtk2->init;                                                                    >
    c::bind_textdomain_codeset($_, 'UTF8') foreach 'libDrakX', @::textdomains;     >
    $::need_utf8_i18n = 1;                                                         >
    Gtk2->croak_execeptions if 0.95 < $Gtk2::VERSION;                              >
}                                                                                  >
====================================================================================>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]