From 7b83735aeac48514e55749e6629003b237919d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 2 Dec 2021 19:02:33 +0100 Subject: [PATCH] wayland/output: Always set xdg_output interface implementation This avoids the following crash, that could happen in certain rare race conditions, e.g. in tests: 0) wl_closure_invoke (closure=0x2fbf9e0, target=0x2e5b3d0, opcode=0) at ../src/connection.c:1014 1) wl_client_connection_data () at ../src/wayland-server.c:432 2) wl_event_loop_dispatch () at ../src/event-loop.c:1027 3) wayland_event_source_dispatch () at ../src/wayland/meta-wayland.c:104 4) g_main_dispatch () at ../glib/gmain.c:3381 Part-of: --- src/wayland/meta-wayland-outputs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wayland/meta-wayland-outputs.c b/src/wayland/meta-wayland-outputs.c index 5631ef616..6c8baa0df 100644 --- a/src/wayland/meta-wayland-outputs.c +++ b/src/wayland/meta-wayland-outputs.c @@ -646,24 +646,25 @@ meta_xdg_output_manager_get_xdg_output (struct wl_client *client, id); wayland_output = wl_resource_get_user_data (output); - if (!wayland_output) - return; - wl_resource_set_implementation (xdg_output_resource, &meta_xdg_output_interface, wayland_output, meta_xdg_output_destructor); + if (!wayland_output) + goto done; + wayland_output->xdg_output_resources = g_list_prepend (wayland_output->xdg_output_resources, xdg_output_resource); if (!wayland_output->monitor) - return; + goto done; send_xdg_output_events (xdg_output_resource, wayland_output, wayland_output->monitor, TRUE, NULL); +done: xdg_output_version = wl_resource_get_version (xdg_output_resource); wl_output_version = wl_resource_get_version (output);