diff options
author | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2016-04-21 16:47:20 +0300 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2016-04-22 10:45:09 +0300 |
commit | fd01ba055d118eaf9b51aac2f93b9a9b697e31a8 (patch) | |
tree | c6ecf1c50021cc9a339053ca95117b0832e5ead1 /tests | |
parent | 13a26e02e5efe176cd8262ccd8203e4225f22613 (diff) | |
download | weston-fd01ba055d118eaf9b51aac2f93b9a9b697e31a8.tar.gz weston-fd01ba055d118eaf9b51aac2f93b9a9b697e31a8.tar.bz2 weston-fd01ba055d118eaf9b51aac2f93b9a9b697e31a8.zip |
tests: check for NULL surface in keyboard and pointer handlers
When a test destroys a wl_surface, it is still possible to get events
referring to the destroyed surface. The surface in such cases will be
NULL.
Handle NULL surface gracefully in keyboard and pointer enter/leave
handlers. Touch-down handler is already NULL-safe.
This fixes a SEGV in a test I am writing for wp_viewport.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/weston-test-client-helper.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c index 3f7ff2b9..cc2544ee 100644 --- a/tests/weston-test-client-helper.c +++ b/tests/weston-test-client-helper.c @@ -132,7 +132,11 @@ pointer_handle_enter(void *data, struct wl_pointer *wl_pointer, { struct pointer *pointer = data; - pointer->focus = wl_surface_get_user_data(wl_surface); + if (wl_surface) + pointer->focus = wl_surface_get_user_data(wl_surface); + else + pointer->focus = NULL; + pointer->x = wl_fixed_to_int(x); pointer->y = wl_fixed_to_int(y); @@ -149,7 +153,7 @@ pointer_handle_leave(void *data, struct wl_pointer *wl_pointer, pointer->focus = NULL; fprintf(stderr, "test-client: got pointer leave, surface %p\n", - wl_surface_get_user_data(wl_surface)); + wl_surface ? wl_surface_get_user_data(wl_surface) : NULL); } static void @@ -243,7 +247,10 @@ keyboard_handle_enter(void *data, struct wl_keyboard *wl_keyboard, { struct keyboard *keyboard = data; - keyboard->focus = wl_surface_get_user_data(wl_surface); + if (wl_surface) + keyboard->focus = wl_surface_get_user_data(wl_surface); + else + keyboard->focus = NULL; fprintf(stderr, "test-client: got keyboard enter, surface %p\n", keyboard->focus); @@ -258,7 +265,7 @@ keyboard_handle_leave(void *data, struct wl_keyboard *wl_keyboard, keyboard->focus = NULL; fprintf(stderr, "test-client: got keyboard leave, surface %p\n", - wl_surface_get_user_data(wl_surface)); + wl_surface ? wl_surface_get_user_data(wl_surface) : NULL); } static void |