force-exit gnucash if a required library can't be loaded.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14206 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2006-05-26 19:45:26 +00:00
parent 177b31b397
commit 5d1ee59cfa
2 changed files with 22 additions and 6 deletions

View File

@ -2,6 +2,9 @@
* src/engine/gnc-engine.c: load the qsf backend from the right place. * src/engine/gnc-engine.c: load the qsf backend from the right place.
* src/engine/gnc-engine.c:
force-exit gnucash if a required library can't be loaded.
2006-05-26 Christian Stimming <stimming@tuhh.de> 2006-05-26 Christian Stimming <stimming@tuhh.de>
* src/import-export/hbci/druid-hbci-initial.c: Simplify calling * src/import-export/hbci/druid-hbci-initial.c: Simplify calling

View File

@ -78,12 +78,13 @@ gnc_engine_init(int argc, char ** argv)
static struct { static struct {
const gchar* dir; const gchar* dir;
const gchar* lib; const gchar* lib;
gboolean required;
} libs[] = { } libs[] = {
{ QOF_LIB_DIR, QSF_BACKEND_LIB }, { QOF_LIB_DIR, QSF_BACKEND_LIB, FALSE },
{ GNC_LIBDIR, GNC_LIB_NAME }, { GNC_LIBDIR, GNC_LIB_NAME, TRUE },
/* shouldn't the PG gnc-module do this instead of US doing it? */ /* shouldn't the PG gnc-module do this instead of US doing it? */
{ GNC_LIBDIR, "gnc-backend-postgres" }, { GNC_LIBDIR, "gnc-backend-postgres", FALSE },
{ NULL, NULL } }, *lib; { NULL, NULL, FALSE } }, *lib;
gnc_engine_init_hook_t hook; gnc_engine_init_hook_t hook;
GList * cur; GList * cur;
@ -103,11 +104,23 @@ gnc_engine_init(int argc, char ** argv)
/* Now register our core types */ /* Now register our core types */
cashobjects_register(); cashobjects_register();
for (lib = libs; lib->dir && lib->lib ; lib++) { for (lib = libs; lib->dir && lib->lib ; lib++)
{
if (qof_load_backend_library(lib->dir, lib->lib)) if (qof_load_backend_library(lib->dir, lib->lib))
{
engine_is_initialized = 1; engine_is_initialized = 1;
}
else else
g_message("failed to load %s from %s", lib->lib, lib->dir); {
g_message("failed to load %s from %s\n", lib->lib, lib->dir);
/* If this is a required library, stop now! */
if (lib->required)
{
g_message("required library %s not found. Exiting.\n",
lib->lib);
g_assert(FALSE);
}
}
} }
/* call any engine hooks */ /* call any engine hooks */