mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-13 15:23:34 +00:00
wayland: Silence a warning if the event thread exits abnormally
Clean up the termination callback if the flush returns with an unrecoverable error to avoid a "queue destroyed while proxies still attached" warning.
This commit is contained in:
@@ -463,19 +463,22 @@ static void Wayland_DestroyCursorThread(SDL_VideoData *data)
|
||||
WAYLAND_wl_proxy_wrapper_destroy(display_wrapper);
|
||||
|
||||
int ret = WAYLAND_wl_display_flush(data->display);
|
||||
if (ret == -1 && errno == EAGAIN) {
|
||||
// The timeout is long, but shutting down the thread requires a successful flush.
|
||||
ret = SDL_IOReady(WAYLAND_wl_display_get_fd(data->display), SDL_IOR_WRITE, SDL_MS_TO_NS(1000));
|
||||
while (ret == -1 && errno == EAGAIN) {
|
||||
// Shutting down the thread requires a successful flush.
|
||||
ret = SDL_IOReady(WAYLAND_wl_display_get_fd(data->display), SDL_IOR_WRITE, -1);
|
||||
if (ret >= 0) {
|
||||
ret = WAYLAND_wl_display_flush(data->display);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the thread to return. Don't wait if the flush failed, or this can hang.
|
||||
if (ret >= 0) {
|
||||
SDL_WaitThread(cursor_thread_context.thread, NULL);
|
||||
// Avoid a warning if the flush failed due to a broken connection.
|
||||
if (ret < 0) {
|
||||
wl_callback_destroy(cb);
|
||||
}
|
||||
|
||||
// Wait for the thread to return; it will exit automatically on a broken connection.
|
||||
SDL_WaitThread(cursor_thread_context.thread, NULL);
|
||||
|
||||
WAYLAND_wl_proxy_wrapper_destroy(cursor_thread_context.compositor_wrapper);
|
||||
WAYLAND_wl_event_queue_destroy(cursor_thread_context.queue);
|
||||
SDL_DestroyMutex(cursor_thread_context.lock);
|
||||
|
||||
Reference in New Issue
Block a user