From 2ab9a306ab44e42a0e1f4f81d3150f6f0b517649 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Thu, 19 Oct 2023 12:58:19 +0200 Subject: [PATCH] Fix /plugins reload error message `/plugins reload non-existent-plugin` printed: ``` Failed to reload plugin: non-existent-plugin, `:^C ``` There were two mistakes: error_message instead of error_message->str was passed to cons_show(). And in case of failing to unload the plugin due to not finding it in the hash table it didn't print an error. This bug was introduced in cc697de05. --- src/command/cmd_funcs.c | 2 +- src/plugins/plugins.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 9e98fb07..e778211b 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -7197,7 +7197,7 @@ cmd_plugins_reload(ProfWin* window, const char* const command, gchar** args) if (res) { cons_show("Reloaded plugin: %s", args[1]); } else { - cons_show("Failed to reload plugin: %s, %s", args[1], error_message); + cons_show("Failed to reload plugin: %s, %s.", args[1], error_message->str); } g_string_free(error_message, TRUE); diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index 5c889395..3dccc881 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -354,6 +354,9 @@ plugins_reload(const char* const name, GString* error_message) gboolean res = plugins_unload(name); if (res) { res = plugins_load(name, error_message); + } else { + log_info("Failed to reload plugin: %s, not loaded", name); + g_string_assign(error_message, "cannot unload"); } return res;