From 26e1e495a05512a67a14fd23f4732670b582f3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 5 Mar 2020 23:29:26 +0100 Subject: [PATCH 03/48] 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 --- src/backends/meta-screen-cast-stream-src.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c index 170f34043..4f3d821ef 100644 --- a/src/backends/meta-screen-cast-stream-src.c +++ b/src/backends/meta-screen-cast-stream-src.c @@ -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); } -- 2.26.0.rc2