mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-22 20:26:17 +01:00
hm, fixup call sequences for check_init() and de_init().
we need to have internal structures in a sane state before we call external functions.
This commit is contained in:
parent
c36aa81e1b
commit
af0977e8e7
@ -66,6 +66,9 @@ g_module_find_by_handle (gpointer handle)
|
||||
{
|
||||
GModule *module;
|
||||
|
||||
if (main_module && main_module->handle == handle)
|
||||
return main_module;
|
||||
|
||||
for (module = modules; module; module = module->next)
|
||||
if (handle == module->handle)
|
||||
return module;
|
||||
@ -180,22 +183,19 @@ g_module_open (const gchar *file_name,
|
||||
module = g_new (GModule, 1);
|
||||
module->file_name = g_strdup (file_name);
|
||||
module->handle = handle;
|
||||
module->ref_count = 0;
|
||||
module->ref_count = 1;
|
||||
module->de_init = NULL;
|
||||
module->next = NULL;
|
||||
module->next = modules;
|
||||
modules = module;
|
||||
|
||||
/* check initialization */
|
||||
if (g_module_symbol (module, "g_module_check_init", &check_init))
|
||||
check_failed = check_init (module);
|
||||
|
||||
/* should call de_init() on failed initializations also? */
|
||||
/* we don't call de_init() if the initialization check failed. */
|
||||
if (!check_failed)
|
||||
g_module_symbol (module, "g_module_de_init", &module->de_init);
|
||||
|
||||
module->ref_count += 1;
|
||||
module->next = modules;
|
||||
modules = module;
|
||||
|
||||
if (check_failed)
|
||||
{
|
||||
g_module_close (module);
|
||||
@ -214,13 +214,15 @@ gboolean
|
||||
g_module_close (GModule *module)
|
||||
{
|
||||
CHECK_ERROR (FALSE);
|
||||
|
||||
|
||||
g_return_val_if_fail (module != NULL, FALSE);
|
||||
g_return_val_if_fail (module->ref_count > 0, FALSE);
|
||||
|
||||
|
||||
if (module != main_module)
|
||||
module->ref_count--;
|
||||
|
||||
|
||||
if (!module->ref_count && module->de_init)
|
||||
module->de_init (module);
|
||||
if (!module->ref_count)
|
||||
{
|
||||
GModule *last;
|
||||
@ -243,9 +245,6 @@ g_module_close (GModule *module)
|
||||
}
|
||||
module->next = NULL;
|
||||
|
||||
if (module->de_init)
|
||||
module->de_init (module);
|
||||
|
||||
_g_module_close (&module->handle, FALSE);
|
||||
g_free (module->file_name);
|
||||
|
||||
|
@ -42,7 +42,7 @@ gplugin_say_boo_func (void)
|
||||
g_print ("GPluginA: BOOH!\n");
|
||||
}
|
||||
|
||||
void
|
||||
G_MODULE_EXPORT void
|
||||
gplugin_a_module_func (GModule *module)
|
||||
{
|
||||
void(*f)(void) = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user