aborting the main loop
- From: Espen S Johnsen <espejohn online no>
- To: gtk-list redhat com
- Subject: aborting the main loop
- Date: 07 Sep 1999 21:38:20 +0200
I think the current main loop code has some shortcomings when using gtk
from languages with exception handling (Common Lisp in my case). The
situasion is like this; if an exception thrown from inside a main loop
is caught outside, the loop code will be left in an inconsistent
state. When one tries to call gtk_main after this, warnings about main
loop already active in another thread are printed.
After looking around in the code a bit, I came up with the following
funcions which seems to work to clean up after an abort:
void
g_main_abort_poll ()
{
poll_waiting = FALSE;
g_slist_free (pending_dispatches);
pending_dispatches = NULL;
}
and
void
gtk_main_abort ()
{
GSList* tmp_list;
g_main_abort_poll();
tmp_list = main_loops;
main_loops = g_slist_remove_link (main_loops, main_loops);
g_main_destroy (tmp_list->data);
gtk_main_loop_level--;
}
I can now wrap the main loop call in an unwind-protect like this:
(unwind-protect
(gtk:main)
(gtk:main-abort))
(things are actally a little bit more complicated than this because the
C code may have called gtk_main internally also)
--
Espen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]