From 10fead9ba14e9212aba187ff2fa4bd41e1fff9bd Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 31 Jan 2014 18:18:59 -0500 Subject: [PATCH] wayland-pointer: Fix infinite loop when leaving focus from a destroyed surface To prevent corruption, our focus listener needs to be removed even when the surface is destroyed. So, bailing out when pointer->focus->resource is NULL just isn't good enough. --- src/wayland/meta-wayland-pointer.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index 193cd4d51..ca65ececa 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -322,12 +322,16 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer, return; resource = pointer->focus_resource; - if (resource && pointer->focus->resource) + if (resource) { - struct wl_client *client = wl_resource_get_client (resource); - struct wl_display *display = wl_client_get_display (client); - serial = wl_display_next_serial (display); - wl_pointer_send_leave (resource, serial, pointer->focus->resource); + if (pointer->focus->resource) + { + struct wl_client *client = wl_resource_get_client (resource); + struct wl_display *display = wl_client_get_display (client); + serial = wl_display_next_serial (display); + wl_pointer_send_leave (resource, serial, pointer->focus->resource); + } + wl_list_remove (&pointer->focus_listener.link); }