screen-cast-stream-src: Don't leak GSource

For every stream src, we created and attached a GSource. Upon stream
src destruction, we g_source_destroy():ed the GSource. What
g_source_destroy() does, hawever, is not really "destroy" it but only
detaches it from the main context removing the reference the context had
added for it via g_source_attach(). This caused the GSource to leak,
although in a detached state, as the reference taken on creation was
still held.

Fix this by also removing our own reference to it when finalizing.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1106
This commit is contained in:
Jonas Ådahl 2020-03-05 23:29:26 +01:00
parent 480e7d44be
commit 26e1e495a0

View File

@ -885,7 +885,7 @@ create_pipewire_source (void)
pipewire_source->pipewire_loop = pw_loop_new (NULL);
if (!pipewire_source->pipewire_loop)
{
g_source_destroy ((GSource *) pipewire_source);
g_source_unref ((GSource *) pipewire_source);
return NULL;
}
@ -980,6 +980,7 @@ meta_screen_cast_stream_src_finalize (GObject *object)
g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
g_source_destroy (&priv->pipewire_source->base);
g_source_unref (&priv->pipewire_source->base);
G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
}