[mutter/wip/carlosg/selection-fixes: 5/8] wayland: Check resource before emitting cancelled event



commit ef4bd19016c586aef2d3451b2700e3149de5a455
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Oct 11 17:47:00 2019 +0200

    wayland: Check resource before emitting cancelled event
    
    If a data source is destroyed we first unset the resource, and try to
    unref unset the related selection source. At this point the only event
    that might be emitted by the internal selection machinery is .cancelled,
    so make sure we avoid it on destroyed sources.
    
    Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/842

 src/wayland/meta-wayland-data-device.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index 24e97222a..3dfedd959 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -1369,7 +1369,8 @@ meta_wayland_source_cancel (MetaWaylandDataSource *source)
   MetaWaylandDataSourceWayland *source_wayland =
     META_WAYLAND_DATA_SOURCE_WAYLAND (source);
 
-  wl_data_source_send_cancelled (source_wayland->resource);
+  if (source_wayland->resource)
+    wl_data_source_send_cancelled (source_wayland->resource);
 }
 
 static void
@@ -1464,7 +1465,8 @@ meta_wayland_data_source_primary_cancel (MetaWaylandDataSource *source)
   MetaWaylandDataSourceWayland *source_wayland;
 
   source_wayland = META_WAYLAND_DATA_SOURCE_WAYLAND (source);
-  gtk_primary_selection_source_send_cancelled (source_wayland->resource);
+  if (source_wayland->resource)
+    gtk_primary_selection_source_send_cancelled (source_wayland->resource);
 }
 
 static void


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