From 75dc8b9d6c2c2f816ecbeffa4d4b048ebc2d5f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Fri, 15 Dec 2023 22:53:51 +0100 Subject: core: fix crash on plugin reload when using musl libs (closes #2052) --- src/plugins/typing/typing.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/plugins/typing/typing.c') diff --git a/src/plugins/typing/typing.c b/src/plugins/typing/typing.c index 8d02928d4..5231fa962 100644 --- a/src/plugins/typing/typing.c +++ b/src/plugins/typing/typing.c @@ -580,6 +580,45 @@ typing_setup_hooks () } } +/* + * Removes all hooks. + */ + +void +typing_remove_hooks () +{ + if (typing_signal_buffer_closing) + { + weechat_unhook (typing_signal_buffer_closing); + typing_signal_buffer_closing = NULL; + } + if (typing_signal_input_text_changed) + { + weechat_unhook (typing_signal_input_text_changed); + typing_signal_input_text_changed = NULL; + } + if (typing_modifier_input_text_for_buffer) + { + weechat_unhook (typing_modifier_input_text_for_buffer); + typing_modifier_input_text_for_buffer = NULL; + } + if (typing_timer) + { + weechat_unhook (typing_timer); + typing_timer = NULL; + } + if (typing_signal_typing_set_nick) + { + weechat_unhook (typing_signal_typing_set_nick); + typing_signal_typing_set_nick = NULL; + } + if (typing_signal_typing_reset_buffer) + { + weechat_unhook (typing_signal_typing_reset_buffer); + typing_signal_typing_reset_buffer = NULL; + } +} + /* * Initializes typing plugin. */ @@ -615,6 +654,8 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) /* make C compiler happy */ (void) plugin; + typing_remove_hooks (); + typing_config_write (); typing_config_free (); -- cgit v1.2.3