QOF should load its own backend libraries.

It shouldn't depend on apps to load QOF libraries.
	  Make sure app-defined backends are used first.
	  Fix a memory leak in qofsession.



git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14208 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2006-05-26 21:45:10 +00:00
parent 0b0a1eeec2
commit 63dfe823fd
3 changed files with 18 additions and 8 deletions

View File

@ -5,6 +5,13 @@
* src/engine/gnc-engine.c:
force-exit gnucash if a required library can't be loaded.
* src/engine/gnc-engine.c:
* lib/libqof/qof/qofsession.c:
QOF should load its own backend libraries.
It shouldn't depend on apps to load QOF libraries.
Make sure app-defined backends are used first.
Fix a memory leak in qofsession.
2006-05-26 Christian Stimming <stimming@tuhh.de>
* src/import-export/hbci/druid-hbci-initial.c: Simplify calling

View File

@ -52,13 +52,14 @@ static QofSession * current_session = NULL;
static GHookList * session_closed_hooks = NULL;
static QofLogModule log_module = QOF_MOD_SESSION;
static GSList *provider_list = NULL;
static gboolean qof_providers_initialized = FALSE;
/* ====================================================================== */
void
qof_backend_register_provider (QofBackendProvider *prov)
{
provider_list = g_slist_prepend (provider_list, prov);
provider_list = g_slist_append (provider_list, prov);
}
/* ====================================================================== */
@ -846,7 +847,7 @@ struct backend_providers
};
/* All available QOF backends need to be described here
and the last entry must be three NULL's.
and the last entry must be two NULL's.
Remember: Use the libdir from the current build environment
and use JUST the module name without .so - .so is not portable! */
struct backend_providers backend_list[] = {
@ -869,9 +870,10 @@ qof_session_load_backend(QofSession * session, char * access_method)
gboolean prov_type;
gboolean (*type_check) (const char*);
ENTER (" list=%d", g_slist_length(provider_list));
ENTER (" list=%d, initted=%s", g_slist_length(provider_list),
qof_providers_initialized ? "true" : "false");
prov_type = FALSE;
if (NULL == provider_list)
if (!qof_providers_initialized)
{
for (num = 0; backend_list[num].filename != NULL; num++) {
if(!qof_load_backend_library(backend_list[num].libdir,
@ -881,8 +883,9 @@ qof_session_load_backend(QofSession * session, char * access_method)
backend_list[num].filename, backend_list[num].libdir);
}
}
qof_providers_initialized = TRUE;
}
p = g_slist_copy(provider_list);
p = provider_list;
while(p != NULL)
{
prov = p->data;
@ -1204,14 +1207,15 @@ qof_session_save (QofSession *session,
if(change_backend == TRUE)
{
qof_session_destroy_backend(session);
if (NULL == provider_list)
if (!qof_providers_initialized)
{
for (num = 0; backend_list[num].filename != NULL; num++) {
qof_load_backend_library(backend_list[num].libdir,
backend_list[num].filename);
}
qof_providers_initialized = TRUE;
}
p = g_slist_copy(provider_list);
p = provider_list;
while(p != NULL)
{
prov = p->data;

View File

@ -80,7 +80,6 @@ gnc_engine_init(int argc, char ** argv)
const gchar* lib;
gboolean required;
} libs[] = {
{ QOF_LIB_DIR, QSF_BACKEND_LIB, FALSE },
{ GNC_LIBDIR, GNC_LIB_NAME, TRUE },
/* shouldn't the PG gnc-module do this instead of US doing it? */
{ GNC_LIBDIR, "gnc-backend-postgres", FALSE },