mirror of https://github.com/libsdl-org/SDL
Fixed memory leak if logging is done after SDL_Quit()
If someone calls SDL_Quit(), then runs an SDL function that implicitly initializes TLS or logging, and then calls SDL_Quit() again, we want to make sure we run through the quit process again. Each of the Init/Quit calls are protected against being called multiple times.
This commit is contained in:
parent
82c89c0125
commit
f080336fa6
13
src/SDL.c
13
src/SDL.c
|
@ -113,7 +113,6 @@ static SDL_bool SDL_MainIsReady = SDL_FALSE;
|
|||
#else
|
||||
static SDL_bool SDL_MainIsReady = SDL_TRUE;
|
||||
#endif
|
||||
static SDL_bool SDL_main_thread_initialized = SDL_FALSE;
|
||||
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
|
||||
static Uint8 SDL_SubsystemRefCount[32];
|
||||
|
||||
|
@ -186,33 +185,21 @@ void SDL_SetMainReady(void)
|
|||
/* Initialize all the subsystems that require initialization before threads start */
|
||||
void SDL_InitMainThread(void)
|
||||
{
|
||||
if (SDL_main_thread_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_InitTLSData();
|
||||
SDL_InitTicks();
|
||||
SDL_InitFilesystem();
|
||||
SDL_InitLog();
|
||||
SDL_InitProperties();
|
||||
SDL_GetGlobalProperties();
|
||||
|
||||
SDL_main_thread_initialized = SDL_TRUE;
|
||||
}
|
||||
|
||||
static void SDL_QuitMainThread(void)
|
||||
{
|
||||
if (!SDL_main_thread_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_QuitProperties();
|
||||
SDL_QuitLog();
|
||||
SDL_QuitFilesystem();
|
||||
SDL_QuitTicks();
|
||||
SDL_QuitTLSData();
|
||||
|
||||
SDL_main_thread_initialized = SDL_FALSE;
|
||||
}
|
||||
|
||||
int SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
|
|
|
@ -118,6 +118,7 @@ void SDL_InitLog(void)
|
|||
void SDL_QuitLog(void)
|
||||
{
|
||||
SDL_ResetLogPriorities();
|
||||
|
||||
if (log_function_mutex) {
|
||||
SDL_DestroyMutex(log_function_mutex);
|
||||
log_function_mutex = NULL;
|
||||
|
|
Loading…
Reference in New Issue