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
This commit is contained in:
Carlos Garnacho 2019-10-11 17:47:00 +02:00
parent e53db92a7b
commit 227d272049

View File

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