(moving to gnucash-devel for the discussion -- is that the best thing
to do, or should we keep the discussion on gnucash-patches?)
Dave Peticolas <[EMAIL PROTECTED]> writes:
> +extern gboolean gnome_is_initialized;
> +
> void
> gnc_ui_shutdown (GtkWidget *widget, gpointer *data)
> {
> - gtk_main_quit ();
> + if (gnome_is_initialized && (gtk_main_level() > 0))
> + gtk_main_quit();
> }
Hmm. This is an improvement, but I suppose we still have to resolve
the overall problem(s).
There are several issues:
We have to address the gtk_main_quit issue. It sounds like once
gtk/gnome is up, if we're in gtk_main then we can't just call exit
anymore. In fact, we're really not supposed to exit the program at
all until gtk_main returns. However, if gtk/gnome hasn't been started
yet, or at least if we're not in gtk_main, then we can call exit to
get out.
So the question is, how do we want to structure things? We could just
say that gnc_shutdown *never* calls exit or directly causes the
program to exit. All it does is set a variable, something like
gnc_is_a_walking_corpse, and then call gtk_main_quit if needed. The
rest is the responsibility of other code.
In some ways, this is a better model because it keeps complex things
from happening during asynchronous X (or other) callbacks if they need
to call gnc_shutdown. However, if we adopted this directly, we'd have
to be a lot more careful in other parts of our code. We'd have to
check all the time to see if shutdown has been called. For example,
presume that gtk_main hasn't been called yet, and we do this during
some of the startup code:
do_something();
if(!try_something()) {
gnc_shutdown();
}
do_something_else();
This won't work because gnc_shutdown doesn't actually do anything
anymore.
To fix this, I think perhaps we need to put more smarts in
gnc_shutdown. It should probably know the current system context well
enough to decide what to do. For example if it's being called after
the gui is up and running (we're inside gtk_main) , it should just
call gtk_main_quit, but if it's being called from "normal",
pre-gtk_main code, then it should handle exiting itself.
Does this cover all the cases?
Thoughts?
--
Rob Browning <[EMAIL PROTECTED]> PGP=E80E0D04F521A094 532B97F5D64E3930
--
Gnucash Developer's List
To unsubscribe send empty email to: [EMAIL PROTECTED]