Don't run SDL_IterateMainCallbacks() if the init call returns an exit code
This fixes a crash in testsprite if you pass invalid command line parameters.main
parent
dad1a84be4
commit
ad5264e54f
|
@ -38,7 +38,7 @@ static void SDLCALL MainCallbackRateHintChanged(void *userdata, const char *name
|
||||||
int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
||||||
{
|
{
|
||||||
int rc = SDL_InitMainCallbacks(argc, argv, appinit, appiter, appevent, appquit);
|
int rc = SDL_InitMainCallbacks(argc, argv, appinit, appiter, appevent, appquit);
|
||||||
|
if (rc == 0) {
|
||||||
SDL_AddHintCallback(SDL_HINT_MAIN_CALLBACK_RATE, MainCallbackRateHintChanged, NULL);
|
SDL_AddHintCallback(SDL_HINT_MAIN_CALLBACK_RATE, MainCallbackRateHintChanged, NULL);
|
||||||
|
|
||||||
Uint64 next_iteration = callback_rate_increment ? (SDL_GetTicksNS() + callback_rate_increment) : 0;
|
Uint64 next_iteration = callback_rate_increment ? (SDL_GetTicksNS() + callback_rate_increment) : 0;
|
||||||
|
@ -72,7 +72,7 @@ int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit,
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DelHintCallback(SDL_HINT_MAIN_CALLBACK_RATE, MainCallbackRateHintChanged, NULL);
|
SDL_DelHintCallback(SDL_HINT_MAIN_CALLBACK_RATE, MainCallbackRateHintChanged, NULL);
|
||||||
|
}
|
||||||
SDL_QuitMainCallbacks();
|
SDL_QuitMainCallbacks();
|
||||||
|
|
||||||
return (rc < 0) ? 1 : 0;
|
return (rc < 0) ? 1 : 0;
|
||||||
|
|
Loading…
Reference in New Issue