From eb732457ea6bcf0d29c38c7558f54da740304464 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 24 Jan 2018 13:36:01 +0100 Subject: [PATCH] Prevent a race between surface destruction and focus The Wayland protocol is asynchronous, by the time we destroy a surface, the compositor may have sent a wl_keyboard::enter or wl_pointer::enter events which now point to no surface, yet we receive it after. To prevent this race, we can just ignore any enter event targetting a NULL surface. Fixes #1150. --- src/wl_init.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wl_init.c b/src/wl_init.c index c8051902..9a60b7a0 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -49,6 +49,10 @@ static void pointerHandleEnter(void* data, wl_fixed_t sx, wl_fixed_t sy) { + // Happens in the case we just destroyed the surface. + if (!surface) + return; + _GLFWwindow* window = wl_surface_get_user_data(surface); _glfw.wl.pointerSerial = serial; @@ -280,6 +284,10 @@ static void keyboardHandleEnter(void* data, struct wl_surface* surface, struct wl_array* keys) { + // Happens in the case we just destroyed the surface. + if (!surface) + return; + _GLFWwindow* window = wl_surface_get_user_data(surface); _glfw.wl.keyboardFocus = window;