wayland/output: Set user data of xdg_output resource

mutter would randomly crash in `send_xdg_output_events()` when changing
the fractional scaling:

  wl_resource_post_event ()
  zxdg_output_v1_send_logical_size ()
  send_xdg_output_events ()
  wayland_output_update_for_output ()
  meta_wayland_compositor_update_outputs ()
  on_monitors_changed ()
  g_closure_invoke ()
  signal_emit_unlocked_R ()
  g_signal_emit_valist ()
  _signal_emit ()
  meta_monitor_manager_notify_monitors_changed ()
  meta_monitor_manager_rebuild ()

This is because the xdg-output resource got freed but wasn't removed
from the list of resources.

Fix this by setting the user data of the xdg-output resource to the
corresponding `MetaWaylandOutput` so that the xdg-output resource
destructor can remove it from the list of resources.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/538
This commit is contained in:
Olivier Fourdan 2019-04-15 14:55:45 +02:00
parent 6ec330ccfa
commit 2c1a951b6e

View File

@ -624,14 +624,14 @@ meta_xdg_output_manager_get_xdg_output (struct wl_client *client,
wl_resource_get_version (resource), wl_resource_get_version (resource),
id); id);
wl_resource_set_implementation (xdg_output_resource,
&meta_xdg_output_interface,
NULL, meta_xdg_output_destructor);
wayland_output = wl_resource_get_user_data (output); wayland_output = wl_resource_get_user_data (output);
if (!wayland_output) if (!wayland_output)
return; return;
wl_resource_set_implementation (xdg_output_resource,
&meta_xdg_output_interface,
wayland_output, meta_xdg_output_destructor);
wayland_output->xdg_output_resources = wayland_output->xdg_output_resources =
g_list_prepend (wayland_output->xdg_output_resources, xdg_output_resource); g_list_prepend (wayland_output->xdg_output_resources, xdg_output_resource);