Browse Source

main: Check for SDL_AddEventWatch failure, now that it can report it.

Ryan C. Gordon 1 year ago
parent
commit
019468dc59
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/main/SDL_main_callbacks.c

+ 5 - 1
src/main/SDL_main_callbacks.c

@@ -67,7 +67,11 @@ int SDL_InitMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, SDL_
             total_pending_events++;
         }
 
-        SDL_AddEventWatch(EventWatcher, NULL);  // !!! FIXME: this should really return an error.
+        if (SDL_AddEventWatch(EventWatcher, NULL) == -1) {
+            SDL_free(pending_events);
+            SDL_AtomicSet(&apprc, -1);
+            return -1;
+        }
 
         for (int i = 0; i < total_pending_events; i++) {
             SDL_PushEvent(&pending_events[i]);