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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2127>
This commit is contained in:
Jonas Ådahl 2021-12-02 19:02:33 +01:00 committed by Marge Bot
parent 50ccab567f
commit 7b83735aea

View File

@ -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);