Exit gnucash from C, not guile.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12882 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker
2006-01-19 05:54:16 +00:00
parent 96276b269d
commit 58a67a439f
3 changed files with 28 additions and 1 deletions

View File

@@ -4,6 +4,8 @@ SUBDIRS = . overrides test
AM_CFLAGS = -I${top_builddir} ${GLIB_CFLAGS} ${GNOME_CFLAGS} ${GTK_CFLAGS} \
${QOF_CFLAGS} \
-I${top_srcdir}/src/gnome-utils \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/gnome \
-I${top_builddir}/src/gnome-utils \
-I${top_srcdir}/src/gnc-module
@@ -11,6 +13,8 @@ bin_PROGRAMS = gnucash-bin
gnucash_bin_SOURCES = gnucash-bin.c
gnucash_bin_LDADD = ${GUILE_LIBS} ${GLIB_LIBS} ${GNOME_LIBS} ${GTK_LIBS} \
${QOF_LIBS} \
${top_builddir}/src/engine/libgncmod-engine.la \
${top_builddir}/src/gnome/libgncgnome.la \
${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
${top_builddir}/src/gnc-module/libgncmodule.la

View File

@@ -35,6 +35,8 @@
#include "i18n.h"
#include "gnc-version.h"
#include "gnc-file.h"
#include "gnc-hooks.h"
#include "top-level.h"
static int gnucash_show_version;
/* GNUCASH_SVN is defined whenever we're building from an SVN tree */
@@ -130,6 +132,25 @@ gnucash_command_line(int argc, char **argv)
poptFreeContext(pc);
}
static void
shutdown(int status)
{
if (gnucash_ui_is_running()) {
if (!gnucash_ui_is_terminating()) {
if (gnc_file_query_save()) {
gnc_hook_run(HOOK_UI_SHUTDOWN, NULL);
gnc_gui_shutdown();
}
}
} else {
gnc_gui_destroy();
gnc_hook_run(HOOK_SHUTDOWN, NULL);
gnc_engine_shutdown();
exit(status);
}
}
static void
inner_main (void *closure, int argc, char **argv)
{
@@ -160,6 +181,7 @@ inner_main (void *closure, int argc, char **argv)
gnc_module_load_optional("gnucash/business-gnome", 0);
scm_c_eval_string("(gnc:main)");
shutdown(0);
return;
}

View File

@@ -563,4 +563,5 @@ string and 'directories' must be a list of strings."
;; command line
(map handle-batch-mode-item (reverse gnc:*batch-mode-things-to-do*)))
(gnc:shutdown 0))
;;return to C
)