From 29141afd0fbc97ba6f981f5df6fa731558dcd13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 28 Oct 2021 15:33:03 +0200 Subject: [PATCH] xwayland: Handle the died callback being cancelled more gracefully If we were cancelled, it could mean we teared down, meaning fetching manager instances will attempt to fetch past freed instances. Handle this by waiting with the fetching until we know we weren't cancelled. Part-of: --- src/wayland/meta-xwayland.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c index 54bb614b0..c6421a430 100644 --- a/src/wayland/meta-xwayland.c +++ b/src/wayland/meta-xwayland.c @@ -536,14 +536,12 @@ xserver_died (GObject *source, GAsyncResult *result, gpointer user_data) { - MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); + MetaWaylandCompositor *compositor; GSubprocess *proc = G_SUBPROCESS (source); MetaDisplay *display = meta_get_display (); g_autoptr (GError) error = NULL; MetaX11DisplayPolicy x11_display_policy; - x11_display_policy = - meta_context_get_x11_display_policy (compositor->context); if (!g_subprocess_wait_finish (proc, result, &error)) { if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -551,7 +549,11 @@ xserver_died (GObject *source, g_warning ("Failed to finish waiting for Xwayland: %s", error->message); } - else if (!g_subprocess_get_successful (proc)) + + compositor = meta_wayland_compositor_get_default (); + x11_display_policy = + meta_context_get_x11_display_policy (compositor->context); + if (!g_subprocess_get_successful (proc)) { if (x11_display_policy == META_X11_DISPLAY_POLICY_MANDATORY) g_warning ("X Wayland crashed; exiting");