[mutter] wayland/output: Set user data of xdg_output resource



commit 2c1a951b6e81ea583e9a83ce29343d7ffd5739d9
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Mon Apr 15 14:55:45 2019 +0200

    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

 src/wayland/meta-wayland-outputs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/wayland/meta-wayland-outputs.c b/src/wayland/meta-wayland-outputs.c
index 7695d86af..099e87ab9 100644
--- a/src/wayland/meta-wayland-outputs.c
+++ b/src/wayland/meta-wayland-outputs.c
@@ -624,14 +624,14 @@ meta_xdg_output_manager_get_xdg_output (struct wl_client   *client,
                                             wl_resource_get_version (resource),
                                             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);
   if (!wayland_output)
     return;
 
+  wl_resource_set_implementation (xdg_output_resource,
+                                  &meta_xdg_output_interface,
+                                  wayland_output, meta_xdg_output_destructor);
+
   wayland_output->xdg_output_resources =
     g_list_prepend (wayland_output->xdg_output_resources, xdg_output_resource);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]