Browse Source

cocoa: Refuse to SDL_Init(SDL_INIT_VIDEO) from background thread.

Fixes #11437.
Reference PR #11502.
Ryan C. Gordon 5 months ago
parent
commit
2b744c7df3
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/video/cocoa/SDL_cocoavideo.m

+ 4 - 0
src/video/cocoa/SDL_cocoavideo.m

@@ -63,6 +63,10 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
         SDL_VideoDevice *device;
         SDL_CocoaVideoData *data;
 
+        if (![NSThread isMainThread]) {
+            return NULL;  // this doesn't SDL_SetError() because SDL_VideoInit is just going to overwrite it.
+        }
+
         Cocoa_RegisterApp();
 
         // Initialize all variables that we clean on shutdown