From 227d27204983f7be20536d79d216f76f80f5cceb Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 11 Oct 2019 17:47:00 +0200 Subject: [PATCH 5/8] wayland: Check resource before emitting cancelled event If a data source is destroyed we first unset the resource, and then try to unref 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 -- 2.23.0