Reduce the possibility of SDL_LockMutex getting called on a destroyed mutex after SDL_StopEventLoop

This commit is contained in:
Sam Lantinga
2024-12-19 09:32:31 -08:00
parent 519923ea80
commit 6e0df0af24

View File

@@ -886,12 +886,17 @@ void SDL_StopEventLoop(void)
} }
SDL_zero(SDL_EventOK); SDL_zero(SDL_EventOK);
SDL_UnlockMutex(SDL_EventQ.lock); SDL_Mutex *lock = NULL;
if (SDL_EventQ.lock) { if (SDL_EventQ.lock) {
SDL_DestroyMutex(SDL_EventQ.lock); lock = SDL_EventQ.lock;
SDL_EventQ.lock = NULL; SDL_EventQ.lock = NULL;
} }
SDL_UnlockMutex(lock);
if (lock) {
SDL_DestroyMutex(lock);
}
} }
// This function (and associated calls) may be called more than once // This function (and associated calls) may be called more than once