pipewire: module-x11-bell: only remove hook if registered

Only remove the module listener if it has actually
been added to the module's listener list.
This commit is contained in:
Barnabás Pőcze 2022-02-17 00:51:27 +01:00
parent 2af3938893
commit 0ed27e570f

View file

@ -86,6 +86,7 @@ struct impl {
struct pw_properties *properties; struct pw_properties *properties;
struct pw_impl_module *module;
struct spa_hook module_listener; struct spa_hook module_listener;
Display *display; Display *display;
@ -204,6 +205,7 @@ static void module_destroy(void *data)
{ {
struct impl *impl = data; struct impl *impl = data;
if (impl->module)
spa_hook_remove(&impl->module_listener); spa_hook_remove(&impl->module_listener);
if (impl->thread_loop) if (impl->thread_loop)
@ -261,6 +263,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
impl->loop = pw_thread_loop_get_loop(impl->thread_loop); impl->loop = pw_thread_loop_get_loop(impl->thread_loop);
impl->properties = args ? pw_properties_new_string(args) : NULL; impl->properties = args ? pw_properties_new_string(args) : NULL;
impl->module = module;
pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl); pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl);
pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_x11_bell_info)); pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_x11_bell_info));