Make sure we call SDL_Quit() before SDLTest_CommonDestroyState()

Otherwise we'll report leaks that will be cleaned up in SDL_Quit()
This commit is contained in:
Sam Lantinga 2024-07-28 07:46:44 -07:00
parent b5ad74998b
commit 728bf363cb
14 changed files with 16 additions and 4 deletions

View File

@ -156,6 +156,8 @@ SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, SDL_InitFlags flags)
/**
* Free the common state object.
*
* You should call SDL_Quit() before calling this function.
*
* \param state The common state object to destroy
*/
void SDLTest_CommonDestroyState(SDLTest_CommonState *state);

View File

@ -134,6 +134,7 @@ void SDL_AppQuit(void *appstate)
{
SDL_DestroyAudioStream(stream);
SDL_free(wave.sound);
SDL_Quit();
SDLTest_CommonDestroyState(state);
}

View File

@ -210,8 +210,8 @@ void SDL_AppQuit(void *appstate)
SDL_DestroyAudioStream(stream_out);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDLTest_CommonDestroyState(state);
SDL_Quit();
SDLTest_CommonDestroyState(state);
}

View File

@ -74,6 +74,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
NULL,
};
SDLTest_CommonLogUsage(state, argv[0], options);
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 1;
}

View File

@ -2243,6 +2243,7 @@ int main(int argc, char *argv[])
result = run_test() ? 0 : 1;
SDL_Quit();
SDLTest_CommonDestroyState(state);
return result;
}

View File

@ -58,6 +58,7 @@ iostrm_error_quit(unsigned line, SDL_IOStream *iostrm)
SDL_CloseIO(iostrm);
}
cleanup();
SDL_Quit();
SDLTest_CommonDestroyState(state);
exit(1); /* quit with iostrm error (test failed) */
}

View File

@ -483,8 +483,8 @@ int main(int argc, char *argv[])
status += Test64Bit(verbose);
status += TestCPUInfo(verbose);
status += TestAssertions(verbose);
SDL_Quit();
SDL_Quit();
SDLTest_CommonDestroyState(state);
return status;

View File

@ -135,6 +135,7 @@ int main(int argc, char *argv[])
test_sort("random sorted", nums, arraylen);
}
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 0;

View File

@ -171,8 +171,8 @@ int main(int argc, char *argv[])
SDL_Log("Reader threads have terminated, quitting!");
SDL_DestroyRWLock(rwlock);
SDLTest_CommonDestroyState(state);
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 0;
}

View File

@ -72,6 +72,7 @@ int main(int argc, char **argv)
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 1;
}
@ -79,6 +80,7 @@ int main(int argc, char **argv)
/* Load the SDL library */
if (SDL_Init(SDL_INIT_SENSOR) < 0) {
SDL_Log("Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 1;
}

View File

@ -149,6 +149,7 @@ int main(int argc, char **argv)
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 1;
}

View File

@ -28,8 +28,8 @@ static SDLTest_CommonState *state;
static void
quit(int rc)
{
SDLTest_CommonDestroyState(state);
SDL_Quit();
SDLTest_CommonDestroyState(state);
/* Let 'main()' return normally */
if (rc != 0) {
exit(rc);

View File

@ -396,6 +396,7 @@ int main(int argc, char **argv)
NULL,
};
SDLTest_CommonLogUsage(state, argv[0], options);
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 1;
}

View File

@ -98,6 +98,7 @@ int main(int argc, char *argv[])
}
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 1;
}