diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/callbacks.c | 25 | ||||
-rw-r--r-- | src/plugins/plugins.c | 19 |
2 files changed, 39 insertions, 5 deletions
diff --git a/src/plugins/callbacks.c b/src/plugins/callbacks.c index d313690b..52f0aebd 100644 --- a/src/plugins/callbacks.c +++ b/src/plugins/callbacks.c @@ -41,6 +41,7 @@ #include "plugins/plugins.h" #include "tools/autocomplete.h" #include "tools/parser.h" +#include "window_list.h" #include "ui/ui.h" @@ -141,9 +142,31 @@ callbacks_init(void) void callbacks_remove(const char *const plugin_name) { - // TODO remove from cmd_ac and cmd_ac_help + GHashTable *command_hash = g_hash_table_lookup(p_commands, plugin_name); + if (command_hash) { + GList *commands = g_hash_table_get_keys(command_hash); + GList *curr = commands; + while (curr) { + char *command = curr->data; + cmd_ac_remove(command); + cmd_ac_remove_help(&command[1]); + curr = g_list_next(curr); + } + g_list_free(commands); + } + g_hash_table_remove(p_commands, plugin_name); g_hash_table_remove(p_timed_functions, plugin_name); + + GHashTable *tag_to_win_cb_hash = g_hash_table_lookup(p_window_callbacks, plugin_name); + GList *tags = g_hash_table_get_keys(tag_to_win_cb_hash); + GList *curr = tags; + while (curr) { + wins_close_plugin(curr->data); + curr = g_list_next(curr); + } + g_list_free(tags); + g_hash_table_remove(p_window_callbacks, plugin_name); } diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index 449bbecf..ea8e7d6a 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -171,10 +171,19 @@ plugins_unload(const char *const name) ProfPlugin *plugin = g_hash_table_lookup(plugins, name); if (plugin) { plugin->on_unload_func(plugin); +#ifdef HAVE_PYTHON + if (plugin->lang == LANG_PYTHON) { + python_plugin_destroy(plugin); + } +#endif +#ifdef HAVE_C + if (plugin->lang == LANG_C) { + c_plugin_destroy(plugin); + } +#endif + prefs_remove_plugin(name); + g_hash_table_remove(plugins, name); } - - prefs_remove_plugin(name); - return TRUE; } @@ -240,7 +249,9 @@ void plugins_win_process_line(char *win, const char * const line) { PluginWindowCallback *window = callbacks_get_window_handler(win); - window->callback_exec(window, win, line); + if (window) { + window->callback_exec(window, win, line); + } } void |