gplugin/gplugin

Address some issues found in review
feature/unload-failed-state
2020-04-11, Gary Kramlich
e876b73d0be2
Parents 40d7a1490169
Children e5c3911cce4f
Address some issues found in review
--- a/gplugin/gplugin-manager.c Fri Apr 10 03:09:02 2020 -0500
+++ b/gplugin/gplugin-manager.c Sat Apr 11 06:11:29 2020 -0500
@@ -900,10 +900,11 @@
gplugin_manager_real_load_plugin(
GPluginManager *manager,
GPluginPlugin *plugin,
- GError **error)
+ GError **ret_error)
{
GPluginPluginInfo *info = NULL;
GPluginLoader *loader = NULL;
+ GError *error = NULL;
gboolean ret = TRUE;
g_return_val_if_fail(GPLUGIN_IS_PLUGIN(plugin), FALSE);
@@ -918,7 +919,7 @@
gchar *filename = gplugin_plugin_get_filename(plugin);
g_set_error(
- error,
+ ret_error,
GPLUGIN_DOMAIN,
0,
_("Plugin %s did not return value plugin info"),
@@ -930,7 +931,7 @@
return FALSE;
}
- if(!gplugin_manager_load_dependencies(plugin, info, error)) {
+ if(!gplugin_manager_load_dependencies(plugin, info, ret_error)) {
g_object_unref(G_OBJECT(info));
return FALSE;
@@ -945,7 +946,7 @@
gchar *filename = gplugin_plugin_get_filename(plugin);
g_set_error(
- error,
+ ret_error,
GPLUGIN_DOMAIN,
0,
_("The loader for %s is not a loader. This "
@@ -958,27 +959,29 @@
return FALSE;
}
- g_signal_emit(manager, signals[SIG_LOADING], 0, plugin, error, &ret);
+ g_signal_emit(manager, signals[SIG_LOADING], 0, plugin, &error, &ret);
if(!ret) {
+ g_propagate_error(ret_error, error);
+
gplugin_plugin_set_state(plugin, GPLUGIN_PLUGIN_STATE_LOAD_FAILED);
return ret;
}
- ret = gplugin_loader_load_plugin(loader, plugin, error);
+ ret = gplugin_loader_load_plugin(loader, plugin, &error);
if(ret) {
gplugin_plugin_set_state(plugin, GPLUGIN_PLUGIN_STATE_LOADED);
-
g_signal_emit(manager, signals[SIG_LOADED], 0, plugin);
- } else {
- GError *real_error = NULL;
- if(error != NULL) {
- real_error = *error;
- }
+ /* just in case a plugin returns TRUE with and error message, free the
+ * error message.
+ */
+ g_clear_error(&error);
+ } else {
+ gplugin_plugin_set_state(plugin, GPLUGIN_PLUGIN_STATE_LOAD_FAILED);
+ g_signal_emit(manager, signals[SIG_LOAD_FAILED], 0, plugin, error);
- gplugin_plugin_set_state(plugin, GPLUGIN_PLUGIN_STATE_LOAD_FAILED);
- g_signal_emit(manager, signals[SIG_LOAD_FAILED], 0, plugin, real_error);
+ g_propagate_error(ret_error, error);
}
return ret;
@@ -1234,7 +1237,7 @@
* @error: A #GError instance.
*
* Emitted when @manager was asked to unload @plugin, but @plugin returned
- * %FALSE when it's unload function was called.
+ * %FALSE when its unload function was called.
*/
signals[SIG_UNLOAD_FAILED] = g_signal_new(
"unload-plugin-failed",
@@ -1688,7 +1691,7 @@
* gplugin_manager_find_plugins_with_state:
* @state: The #GPluginPluginState to look for.
*
- * Finds all plugins that are currently have a state of @state.
+ * Finds all plugins that currently have a state of @state.
*
* Returns: (element-type GPlugin.Plugin) (transfer full): A #GSList of
* referenced #GPluginPlugin's whose state is @state. Call
--- a/gplugin/tests/test-find-plugins.c Fri Apr 10 03:09:02 2020 -0500
+++ b/gplugin/tests/test-find-plugins.c Sat Apr 11 06:11:29 2020 -0500
@@ -58,8 +58,8 @@
* their state each iteration while checking that
* gplugin_manager_find_plugins_with_state() returns the correct values.
*
- * If any changes are made to the that plugins directory, this test will need
- * to be updated.
+ * If any changes are made to the plugins directory, this test will need to be
+ * updated.
*/
static void
test_gplugin_manager_find_plugins_with_state(void)