From 3f2e5d569dc4879ce3b30751faaa9c6045b24396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Mon, 17 Jun 2024 19:26:11 +0200 Subject: [PATCH] clapper-gtk: video: Fix signals disconnection after dispose A possibility exists that something else keeps a reference to the player even after video is disposed. In this case signals from the player would not be disconnected. We have to disconnect them manually here to ensure their callbacks will not be used after disposal. --- src/lib/clapper-gtk/clapper-gtk-video.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib/clapper-gtk/clapper-gtk-video.c b/src/lib/clapper-gtk/clapper-gtk-video.c index a5322baf..3d5e73ae 100644 --- a/src/lib/clapper-gtk/clapper-gtk-video.c +++ b/src/lib/clapper-gtk/clapper-gtk-video.c @@ -1447,6 +1447,24 @@ clapper_gtk_video_dispose (GObject *object) g_clear_handle_id (&self->fade_timeout, g_source_remove); + /* Something else might still be holding a reference on the player, + * thus we should disconnect everything before disposing template */ + if (self->player) { + ClapperQueue *queue = clapper_player_get_queue (self->player); + + g_signal_handlers_disconnect_by_func (self->player, + _player_state_changed_cb, self); + g_signal_handlers_disconnect_by_func (self->player, + _video_sink_changed_cb, self); + g_signal_handlers_disconnect_by_func (self->player, + _player_error_cb, self); + g_signal_handlers_disconnect_by_func (self->player, + _player_missing_plugin_cb, self); + + g_signal_handlers_disconnect_by_func (queue, + _queue_current_item_changed_cb, self); + } + gtk_widget_dispose_template (GTK_WIDGET (object), CLAPPER_GTK_TYPE_VIDEO); g_clear_pointer (&self->overlay, gtk_widget_unparent);