1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Remove plugin callbacks in plugin_destroy functions

This commit is contained in:
James Booth 2016-07-04 22:54:55 +01:00
parent 0d7b4cb4a7
commit c8d09083a8
4 changed files with 12 additions and 1 deletions

View File

@ -523,6 +523,8 @@ c_plugin_destroy(ProfPlugin *plugin)
{
assert (plugin && plugin->module);
callbacks_remove(plugin->name);
if (dlclose (plugin->module)) {
log_warning ("dlclose failed to close `%s' with `%s'", plugin->name, dlerror ());
}

View File

@ -138,7 +138,14 @@ callbacks_init(void)
p_window_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_free_window_callbacks);
}
// TODO move to plugin destroy functions
void
callbacks_remove(const char *const plugin_name)
{
g_hash_table_remove(p_commands, plugin_name);
g_hash_table_remove(p_timed_functions, plugin_name);
g_hash_table_remove(p_window_callbacks, plugin_name);
}
void
callbacks_close(void)
{

View File

@ -64,6 +64,7 @@ typedef struct p_window_input_callback {
} PluginWindowCallback;
void callbacks_init(void);
void callbacks_remove(const char *const plugin_name);
void callbacks_close(void);
void callbacks_add_command(const char *const plugin_name, PluginCommand *command);

View File

@ -889,6 +889,7 @@ void
python_plugin_destroy(ProfPlugin *plugin)
{
disable_python_threads();
callbacks_remove(plugin->name);
free(plugin->name);
Py_XDECREF(plugin->module);
free(plugin);