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.
This commit is contained in:
Rafał Dzięgiel
2024-06-17 19:26:11 +02:00
parent 7cd0d3782d
commit 3880357af4

View File

@@ -1451,6 +1451,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);