Browse Source

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.
Frank Praznik 3 weeks ago
parent
commit
64bf432beb
1 changed files with 9 additions and 6 deletions
  1. 9 6
      src/video/wayland/SDL_waylandmouse.c

+ 9 - 6
src/video/wayland/SDL_waylandmouse.c

@@ -463,19 +463,22 @@ static void Wayland_DestroyCursorThread(SDL_VideoData *data)
         WAYLAND_wl_proxy_wrapper_destroy(display_wrapper);
         WAYLAND_wl_proxy_wrapper_destroy(display_wrapper);
 
 
         int ret = WAYLAND_wl_display_flush(data->display);
         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) {
             if (ret >= 0) {
                 ret = WAYLAND_wl_display_flush(data->display);
                 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_proxy_wrapper_destroy(cursor_thread_context.compositor_wrapper);
         WAYLAND_wl_event_queue_destroy(cursor_thread_context.queue);
         WAYLAND_wl_event_queue_destroy(cursor_thread_context.queue);
         SDL_DestroyMutex(cursor_thread_context.lock);
         SDL_DestroyMutex(cursor_thread_context.lock);