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 df371c698a
commit 3f2e5d569d

View File

@@ -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);