diff options
| author | shironeko <shironeko@tesaguri.club> | 2022-05-19 10:21:07 -0400 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2022-05-19 09:38:00 -0600 |
| commit | 689140c20446ce8b1a7dc8f4ca553d49bb4d53a4 (patch) | |
| tree | 8c0a4b502ad9fd8427ec099fb8bbbf04e111949e /cube/cube.cpp | |
| parent | 2091e30731347ce1362f021016a46500fa0e6e0f (diff) | |
| download | usermoji-689140c20446ce8b1a7dc8f4ca553d49bb4d53a4.tar.xz | |
cube: add null check on wl_*_destroy functions
Encountered the crash on a compositor without keyboard, this seems to
fix it.
Diffstat (limited to 'cube/cube.cpp')
| -rw-r--r-- | cube/cube.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cube/cube.cpp b/cube/cube.cpp index e984fabb..9b4ac1a3 100644 --- a/cube/cube.cpp +++ b/cube/cube.cpp @@ -495,7 +495,7 @@ static void seat_handle_capabilities(void *data, wl_seat *seat, uint32_t caps) { if (caps & WL_SEAT_CAPABILITY_KEYBOARD) { demo.keyboard = wl_seat_get_keyboard(seat); wl_keyboard_add_listener(demo.keyboard, &keyboard_listener, &demo); - } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD)) { + } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && demo.keyboard) { wl_keyboard_destroy(demo.keyboard); demo.keyboard = nullptr; } @@ -601,9 +601,9 @@ void Demo::cleanup() { xcb_disconnect(connection); free(atom_wm_delete_window); #elif defined(VK_USE_PLATFORM_WAYLAND_KHR) - wl_keyboard_destroy(keyboard); - wl_pointer_destroy(pointer); - wl_seat_destroy(seat); + if (keyboard) wl_keyboard_destroy(keyboard); + if (pointer) wl_pointer_destroy(pointer); + if (seat) wl_seat_destroy(seat); xdg_toplevel_destroy(window_toplevel); xdg_surface_destroy(window_surface); wl_surface_destroy(window); |
