Re: how to fully quit out of recursive main loops?
- From: Paul Davis <pbd Op Net>
- To: Havoc Pennington <hp redhat com>
- Cc: gtk-list gnome org
- Subject: Re: how to fully quit out of recursive main loops?
- Date: Fri, 25 Jan 2002 12:47:27 -0500
>> why would i want to? imagine the user takes some steps to invoke
>> a "quit" function. if there are nested main loops (e.g to run a
>> dialog), gtk_main_quit() won't work as a way to return control to
>> whatever called gtk_main_run() at the top level.
>
>People sometimes write "while (gtk_main_level ()) gtk_main_quit()"
>but I think it's a big old hack.
it doesn't work either. gtk_main_quit() just marks the loop as not
running. the level won't change till the current main loop regains
control. this code will run forever :)
>> ideas?
>
>In my code the policy I use is that I never nest gtk_main(); for
>recursive loops I create my own separate
>GMainLoop. e.g. gtk_dialog_run does this. This avoids confusion. Then
>I only use gtk_dialog_run sort of stuff if the dialog is modal.
but that would then require that the GMainLoop you create be "global",
because the quit function activated by the user (e.g. a keyboard
entry, a control protocol message, a MIDI event, or some other
not-modally-restricted method) would have to know about. i suppose
what i'm looking for is:
g_main_quit_all ();
which would apply g_main_quit() to all current main loops.
it seems like a rather serious design defect, though hardly surpising
given the reprehensible way that gtk_exit() works (calling exit(2)). i
would have thought that a way to say "stop the GUI and release its
resources" was rather important :)
oh well, setjmp/longjmp seems to be it :(
--p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]