> (moving to gnucash-devel for the discussion -- is that the best thing
>  to do, or should we keep the discussion on gnucash-patches?)

No, this is good.

> 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).


Yes, I agree. This fix was just to prevent gtk_main_quit() from
being called before gtk_main() or gnome_init().


> There are several issues:
> 
> 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.

I think we should have a clean separation between shutting down
the ui and shutting down guile, since guile can be running without
the ui. As I understand things, it will never be the case that the
ui is running without guile. Right?

Also, if we are running as a shell, we ought to be able to
start the ui, do stuff, and then exit the ui dropping back
into the shell.

I think that gnc:lowlev-app-main should terminate normally, not
with an exit, so that the guile gnc:main cleans up at the end.
Using ideas from your second message, I think there should be
ui-shutdown hooks (called just before the ui shuts down) and
guile-shutdown hooks (called by guile after the ui shuts down.

So here are the cases. If a procedure has a ':' in the name,
it is guile, otherwise it is C.

1. Neither guile nor the gui is running.

   gnc:shutdown can't be called.

   Calling gnc_shutdown should just exit, nothing else.

   This seems to be a degenerate case, since the only place
   in the code where this is true is in the first few lines
   of gnucash.c main(), right?

2. Guile is running, but the ui is not.

   gnc:shutdown should run the guile-shutdown hooks and exit.

   gnc_shutdown should call gnc:shutdown.

3. Guile is running and the gui is running.

   gnc:shutdown should invoke gnc:ui_shutdown (defined below).

   gnc_shutdown should call gnc:shutdown.

   gnc:ui_shutdown should
     1. Call the ui-shutdown hooks, which should include
        gncFileQuerySave and gncFileQuit.
     2. Call gnc_ui_shutdown which calls gtk_main_quit()
        or the motif equivalent (is there one?)

Now, when both are running, the following will happen during a shutdown,
if we aren't running as a shell:

1. gnc_shutdown will be invoked, invoking gnc:shutdown
2. gnc:ui_shutdown will be invoked.
3. ui-shutdown hooks will be called.
4. gnc_ui_shutdown will be called and gnome/motif is told to stop.
5. gnc_ui_shutdown and gnc:ui_shutdown will fall out.
6. gnc:shutdown and gnc_shutdown will fall out.
7. ui will shutdown, and we will fall out of the
   low level main into the guile main.
8. gnc:shutdown will be called (again).
9. guile-shutdown hooks called.
10. exit    whew!

If we are running as a shell, then at step 6, we will
just fall back into the shell, (unless we actually
invoked gnc:main from the shell).

What do you think?

dave

--
Gnucash Developer's List 
To unsubscribe send empty email to: [EMAIL PROTECTED]

Reply via email to