diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-07-31 22:10:11 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-07-31 22:10:11 (GMT) |
commit | b8c868d42b0788bc6e41f3e8368d507f0d338687 (patch) | |
tree | e09c9d59f69c200a49bf6f87226f38f46bffa92b /src/plugins | |
parent | d79100f78dc6b4fcaf0533c8f62bfe090090731d (diff) |
Added extra error messages to improve plugin loading.
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/plugin.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index f7a52dd..dabb4b6 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -244,27 +244,25 @@ GPluginModule *g_plugin_module_new(const gchar *filename) /* Récupération de la version d'ABI */ if (!load_plugin_symbol(module, "_chrysalide_plugin", &interface)) - goto bad_plugin; + goto no_interface; current = CURRENT_ABI_VERSION; if (current != interface->abi_version) - { - log_variadic_message(LMT_ERROR, - _("ABI mismatch detected! Plugin '%s' rejected"), - filename); - goto bad_plugin; - - } + goto wrong_abi; /* Localisation des différents points d'entrée déclarés */ -#define check_plugin_symbol(mod, sym) \ - ({ \ - bool __result; \ - __result = g_module_symbol(mod, sym, (gpointer []) { NULL }); \ - __result; \ +#define check_plugin_symbol(mod, sym) \ + ({ \ + bool __result; \ + __result = g_module_symbol(mod, sym, (gpointer []) { NULL }); \ + if (!__result) \ + log_variadic_message(LMT_ERROR, \ + _("No '%s' entry in plugin candidate '%s'"), \ + sym, filename); \ + __result; \ }) @@ -448,13 +446,13 @@ GPluginModule *g_plugin_module_new(const gchar *filename) } if (!valid) - goto bad_plugin; + goto missing_feature; gtype = build_dynamic_type(G_TYPE_PLUGIN_MODULE, interface->gtp_name, (GClassInitFunc)g_plugin_module_init_gclass, module, NULL); if (gtype == G_TYPE_INVALID) - goto bad_plugin; + goto no_instance; result = g_object_new(gtype, NULL); @@ -465,6 +463,25 @@ GPluginModule *g_plugin_module_new(const gchar *filename) return result; + no_interface: + + log_variadic_message(LMT_ERROR, _("Main interface is missing for plugin '%s'"), filename); + goto bad_plugin; + + wrong_abi: + + log_variadic_message(LMT_ERROR, _("ABI mismatch detected! Plugin '%s' rejected"), filename); + goto bad_plugin; + + missing_feature: + + log_variadic_message(LMT_ERROR, _("An expected feature is missing for plugin '%s'"), filename); + goto bad_plugin; + + no_instance: + + log_variadic_message(LMT_ERROR, _("Unabled to create an instance of plugin '%s'"), filename); + bad_plugin: g_module_close(module); |