From 2b744c7df3bb4da133c7bd69df0bc0cf1846e7af Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 20 Nov 2024 20:22:36 -0500 Subject: [PATCH] cocoa: Refuse to SDL_Init(SDL_INIT_VIDEO) from background thread. Fixes #11437. Reference PR #11502. --- src/video/cocoa/SDL_cocoavideo.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 93b9153171..c2c0bb3be0 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/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