wayland: Handle wl_data_device being destroyed while focused

A wl_data_device object may be created while it is being focused,
either because the client destroyed it or because the client was
destroyed. Handle this by early out in focus handler vfuncs the case
where it was destroyed, so that we don't corrupt memory and/or cause
segmentation fault.

https://bugzilla.gnome.org/show_bug.cgi?id=765062
This commit is contained in:
Jonas Ådahl 2016-04-25 18:42:57 +08:00
parent ed5c3b39ee
commit 08ac192b9d

View File

@ -1424,9 +1424,10 @@ meta_wayland_drag_dest_focus_out (MetaWaylandDataDevice *data_device,
{
MetaWaylandDragGrab *grab = data_device->current_grab;
if (grab->drag_focus_data_device)
wl_data_device_send_leave (grab->drag_focus_data_device);
if (!grab->drag_focus_data_device)
return;
wl_data_device_send_leave (grab->drag_focus_data_device);
wl_list_remove (&grab->drag_focus_listener.link);
grab->drag_focus_data_device = NULL;
}
@ -1439,6 +1440,9 @@ meta_wayland_drag_dest_motion (MetaWaylandDataDevice *data_device,
MetaWaylandDragGrab *grab = data_device->current_grab;
wl_fixed_t sx, sy;
if (!grab->drag_focus_data_device)
return;
meta_wayland_pointer_get_relative_coordinates (grab->generic.pointer,
grab->drag_focus,
&sx, &sy);
@ -1453,6 +1457,9 @@ meta_wayland_drag_dest_drop (MetaWaylandDataDevice *data_device,
{
MetaWaylandDragGrab *grab = data_device->current_grab;
if (!grab->drag_focus_data_device)
return;
wl_data_device_send_drop (grab->drag_focus_data_device);
}