From 08593ea8721846b9236004e8e4819ad0d1844548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 3 Mar 2023 14:59:21 +0100 Subject: [PATCH] onscreen/native: Hold ref to the output and CRTC until detached When an onscreen is "attached" it means it has an active CRTC and output it interacts with, e.g. listens to configuration changes to update gamma and privacy screen state. MetaOutput and MetaCrtc are rather short lived objects meaning they are disposed of and regenerated each time the compositor reloads monitor resources, and while MetaOutput are indirectly kept alive due to the MetaMonitor holding on to them during reloading, the same does not apply to MetaCrtc, so to avoid trying to disconnect our signals from disappeared outputs and CRTCs when we dispatch, hold our own references to these objects. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2665 Part-of: --- src/backends/native/meta-onscreen-native.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index b76d0f98c..b73793d38 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -2251,8 +2251,9 @@ meta_onscreen_native_new (MetaRendererNative *renderer_native, onscreen_native->renderer_native = renderer_native; onscreen_native->render_gpu = render_gpu; - onscreen_native->output = output; - onscreen_native->crtc = crtc; + + g_set_object (&onscreen_native->output, output); + g_set_object (&onscreen_native->crtc, crtc); if (meta_crtc_get_gamma_lut_size (crtc) > 0) { @@ -2368,4 +2369,6 @@ void meta_onscreen_native_detach (MetaOnscreenNative *onscreen_native) { clear_invalidation_handlers (onscreen_native); + g_clear_object (&onscreen_native->output); + g_clear_object (&onscreen_native->crtc); }