Dave Peticolas wrote:
> 
> > Dave Peticolas wrote:
> >
> > >
> > > Is it really necessary to install a destroy callback?
> > > I though the default would suffice in this case.
> > >
> >
> > Actually, the destroy callback is not needed at all.  You'll notice that it
> > doesn't actually do anything, it just returns FALSE.  The destroy callback
> > is called just before the main window widget is closed so you can do some
> > final cleanup.  I thought I would need it, but I didn't, and I forgot to
> > remove it before creating the patch.
> >
> > However, it might make sense to add a call to gtk_main_quit() in the destroy
> > event callback to make sure that the application exits when a destroy event
> > occurs without a delete event before it.  Can somebody else elaborate on
> > this?
> 
> Since gnucash doesn't seem to be explicitly destroying the
> main window anywhere, I would have thought that this scenario
> would be impossible.

You're right, it should be impossible.  However, if a bug causes the
main window to exit, then the program should exit gracefully as the
current design of gnucash-gnome depends on the main window being open.

> 
> > >
> > > Also, is it ok to shutdown the program without letting
> > > the gtk main loop finish?
> > >
> >
> > The comment on the delete event callback is misleading.  It should read:
> >
> > /* return TRUE when gnc_shutdown(0) returns because we are only
> >  * requesting to quit the program, and we don't want to close the window yet
> > */
> >
> > Delete events are on the window, not the application.  If we returned FALSE,
> > then the window would close, but the gtk main loop would still be running,
> > and the program would have to be killed.  calling gnc_shutdown(0) brings up
> > the "Do you want to save?" dialog box, and eventually calls gtk_main_quit().
> 
> As I understand the main loop operation, gtk_main_quit() just
> unsets a 'running' flag. I thought we still needed to let the
> main loop fall out of the gtk_main() call.
> 

Here you're also right, I was mistaken.  I played with it tonight, and
gtk_main_quit() does indeed return to the calling procedure.  However,
gnc_shutdown() does not exit the program.  It just initiates a series of
events which may ultimatly result in gtk_main_quit() being called, and
then the program exiting normally.  gnc_shutdown() does things like
check if there are any unsaved files and asks the user if they want to
save unsaved changes.  Note, however, that when gtk_main_quit() opens a
"Do yoiu want to save" dialog box, it still immediately returns back to
the caller.

Later,
G.

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

Reply via email to