Do not register qof backend modules on first load, #433779.

Qof backend modules used to call qof_backend_register_provider() and
g_module_make_resident() directly in g_module_check_init(), i.e. they
could not be unloaded after the gnucash module crawler detected them.
Probably after the renaming of libgnc-backend-file the QSF backend
module started to register itself before the gnc file backend, spitting
a validation error on virtually every data file load.

So g_module_check_init() has been renamed to qof_backend_module_init()
and is now called by qof_load_backend_library().


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16200 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andreas Köhler 2007-06-22 13:31:29 +00:00
parent 0bca303440
commit dfde8ebcb7
7 changed files with 16 additions and 18 deletions

View File

@ -159,8 +159,8 @@ Initialises the backend and provides access to the
functions that will load and save the data. Initialises
default values for the QofBackendOption KvpFrame.
*/
G_MODULE_EXPORT const gchar *
g_module_check_init(GModule *module);
G_MODULE_EXPORT void
qof_backend_module_init(void);
/** \name Supported backend configurations
@{

View File

@ -1268,8 +1268,8 @@ qsf_provider_free (QofBackendProvider *prov)
g_free (prov);
}
G_MODULE_EXPORT const gchar *
g_module_check_init(GModule *module)
G_MODULE_EXPORT void
qof_backend_module_init (void)
{
QofBackendProvider *prov;
@ -1281,6 +1281,4 @@ g_module_check_init(GModule *module)
prov->check_data_type = qsf_determine_file_type;
prov->provider_free = qsf_provider_free;
qof_backend_register_provider (prov);
g_module_make_resident (module);
return NULL;
}

View File

@ -388,6 +388,7 @@ qof_load_backend_library (const char *directory, const char* module_name)
{
gchar *fullpath;
GModule *backend;
void (*module_init_func) (void);
g_return_val_if_fail(g_module_supported(), FALSE);
fullpath = g_module_build_path(directory, module_name);
@ -396,8 +397,10 @@ qof_load_backend_library (const char *directory, const char* module_name)
g_message ("%s: %s\n", PACKAGE, g_module_error ());
return FALSE;
}
if (g_module_symbol(backend, "qof_backend_module_init",
(gpointer)&module_init_func))
module_init_func();
/* the module should have done that already in g_module_check_init */
g_module_make_resident(backend);
return TRUE;
}

View File

@ -1057,8 +1057,8 @@ gnc_provider_free (QofBackendProvider *prov)
g_free (prov);
}
G_MODULE_EXPORT const gchar *
g_module_check_init(GModule *module)
G_MODULE_EXPORT void
qof_backend_module_init(void)
{
QofBackendProvider *prov;
prov = g_new0 (QofBackendProvider, 1);
@ -1069,8 +1069,6 @@ g_module_check_init(GModule *module)
prov->provider_free = gnc_provider_free;
prov->check_data_type = gnc_determine_file_type;
qof_backend_register_provider (prov);
g_module_make_resident (module);
return NULL;
}
/* ========================== END OF FILE ===================== */

View File

@ -56,7 +56,7 @@ typedef struct FileBackend_struct FileBackend;
// This is now a static inside the module
//QofBackend * libgncmod_backend_file_LTX_gnc_backend_new(void);
G_MODULE_EXPORT const gchar *
g_module_check_init(GModule *module);
G_MODULE_EXPORT void
qof_backend_module_init(void);
#endif /* GNC_BACKEND_FILE_H_ */

View File

@ -2536,8 +2536,8 @@ pg_provider_free (QofBackendProvider *prov)
g_free (prov);
}
G_MODULE_EXPORT const gchar *
g_module_check_init(GModule *module)
G_MODULE_EXPORT void
qof_backend_module_init(void)
{
QofBackendProvider *prov;
@ -2549,7 +2549,6 @@ g_module_check_init(GModule *module)
prov->provider_free = pg_provider_free;
prov->check_data_type = NULL;
qof_backend_register_provider (prov);
return NULL;
}
/* ======================== END OF FILE ======================== */

View File

@ -133,7 +133,7 @@ QofBook * pgendGetBook(PGBackend *pbe);
void pgendDisable (PGBackend *be);
void pgendEnable (PGBackend *be);
G_MODULE_EXPORT const gchar *
g_module_check_init(GModule *module);
G_MODULE_EXPORT void
qof_backend_module_init(void);
#endif /* POSTGRES_BACKEND_H */