Dave Peticolas <[EMAIL PROTECTED]> writes:

> 1. Get a 'pointer' to the scheme gnc:shutdown code.
> 
> 2. Evaluate that code.

but only if guile_is_initialized.

> The scheme shutdown code (src/scm/main.scm) then does the following:
> 
> 1. Run any shutdown hooks that have been registered.

Yep.

> 2. Run _gnc_shutdown which does the "do you want to save" thing.
>    Note that the user can choose to save or not save at this point,
>    but not to abort the shutdown.
>    The last thing _gnc_shutdown does is gtk_main_quit()

Yep, and every time I go back and look at this code, I get briefly
confused.  I'm so used to thinking in terms of multi-threaded apps,
every time I see the gnc:shutdown in main just after the
gnc:lowlev-app-main call, I think there's a bug because I expect this
to get executed just after gtk_main_quit pops us back out of gtk_main.

However, this will never happen because there's only one thread of
control, and it's already in the middle of gtk:shutdown.

Arguably, all of this could be restructured so that we let the
gnc:shutdown after gnc:lowlev-app-main handle things, but this only
works if you're already happily running the gui, and you know that
things are well enough to wait for things to "fall through".

Is it a problem to go ahead and exit after gtk_main_quit returns?  I
guess I had just presumed that it wouldn't return until everything
that was important had been cleaned up, but thinking about it, I
suppose it's equally likely that it could return immediately and
expect you to wait until gtk_main returns before you do something
drastic like call exit.

> 3. The last thing the scheme shutdown code does is invoke
>    the scheme function 'exit', which I believe is a
>    full-blown exit.

Yep.

> I think we should shutdown scheme after we exit gtk_main.
> Or, more generally, we should shutdown scheme after we
> shutdown the ui, since the ui is started after scheme.
>
> Thus, when we get a delete_event on the main window,
> or the File/Quit is selected, etc., I think we should:
> 
> 1. Do the "do you want to save thing", etc.
> 2. gtk_main_quit().
> 
> Then, when gtk_main() falls out, we shut down scheme.
> Of course, this would also affect how things are done
> on the Motif side as well.

OK, I'm happy to entertain this as a possible improvement, but we have
to be careful to handle all the right cases (or change the rest of the
code to conform with whatever new semantics we agree on).  Right now
it's expected that these things be true:

  1) gnc_shutdown and gnc:shutdown should be interchangable.

  2) They exits the program with the given status after calling any
     shutdown hooks (if guile is initialized).

  3) They do the right thing whether or not the GUI or guile are up
     and running.

-- 
Rob Browning <[EMAIL PROTECTED]> PGP=E80E0D04F521A094 532B97F5D64E3930

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

Reply via email to