From dad1931b5f4a64d105554681ec84d859f020d6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 6 Oct 2015 14:30:28 +0800 Subject: [PATCH] wayland: Don't ignore wl_keyboard.leave if surface is gone keyboard_handle_leave() might be called with a NULL surface resource (for example if the surface was destroyed after the event was sent). If so, we should still deal with the keyboard focus lost event, otherwise we will both leak (the keyboard_focus GdkWindow reference) and miss stopping the key repeat timer. https://bugzilla.gnome.org/show_bug.cgi?id=755927 --- gdk/wayland/gdkdevice-wayland.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 92548858c1..b6e3fd0193 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -1191,15 +1191,14 @@ keyboard_handle_leave (void *data, GdkEvent *event; GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display); - if (!surface) - return; - - if (!GDK_IS_WINDOW (wl_surface_get_user_data (surface))) - return; - if (!device->keyboard_focus) return; + /* gdk_window_is_destroyed() might already return TRUE for + * device->keyboard_focus here, which would happen if we destroyed the + * window before loosing keyboard focus. + */ + stop_key_repeat (device); _gdk_wayland_display_update_serial (display, serial);