mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-14 13:56:00 +00:00
@@ -130,10 +130,10 @@ SDL_AppResult SDL_IterateMainCallbacks(bool pump_events)
|
||||
return rc;
|
||||
}
|
||||
|
||||
void SDL_QuitMainCallbacks(void)
|
||||
void SDL_QuitMainCallbacks(SDL_AppResult result)
|
||||
{
|
||||
SDL_RemoveEventWatch(SDL_MainCallbackEventWatcher, NULL);
|
||||
SDL_main_quit_callback(SDL_main_appstate);
|
||||
SDL_main_quit_callback(SDL_main_appstate, result);
|
||||
SDL_main_appstate = NULL; // just in case.
|
||||
|
||||
// for symmetry, you should explicitly Quit what you Init, but we might come through here uninitialized and SDL_Quit() will clear everything anyhow.
|
||||
|
@@ -25,7 +25,7 @@
|
||||
bool SDL_HasMainCallbacks(void);
|
||||
SDL_AppResult SDL_InitMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func _appiter, SDL_AppEvent_func _appevent, SDL_AppQuit_func _appquit);
|
||||
SDL_AppResult SDL_IterateMainCallbacks(bool pump_events);
|
||||
void SDL_QuitMainCallbacks(void);
|
||||
void SDL_QuitMainCallbacks(SDL_AppResult result);
|
||||
|
||||
#endif // SDL_main_callbacks_h_
|
||||
|
||||
|
@@ -28,7 +28,7 @@ static void EmscriptenInternalMainloop(void)
|
||||
{
|
||||
const SDL_AppResult rc = SDL_IterateMainCallbacks(true);
|
||||
if (rc != SDL_APP_CONTINUE) {
|
||||
SDL_QuitMainCallbacks();
|
||||
SDL_QuitMainCallbacks(rc);
|
||||
emscripten_cancel_main_loop(); // kill" the mainloop, so it stops calling back into it.
|
||||
exit((rc == SDL_APP_FAILURE) ? 1 : 0); // hopefully this takes down everything else, too.
|
||||
}
|
||||
@@ -40,7 +40,7 @@ int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit,
|
||||
if (rc == SDL_APP_CONTINUE) {
|
||||
emscripten_set_main_loop(EmscriptenInternalMainloop, 0, 0); // run at refresh rate, don't throw an exception since we do an orderly return.
|
||||
} else {
|
||||
SDL_QuitMainCallbacks();
|
||||
SDL_QuitMainCallbacks(rc);
|
||||
}
|
||||
return (rc == SDL_APP_FAILURE) ? 1 : 0;
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit,
|
||||
|
||||
SDL_RemoveHintCallback(SDL_HINT_MAIN_CALLBACK_RATE, MainCallbackRateHintChanged, NULL);
|
||||
}
|
||||
SDL_QuitMainCallbacks();
|
||||
SDL_QuitMainCallbacks(rc);
|
||||
|
||||
return (rc == SDL_APP_FAILURE) ? 1 : 0;
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ static SDLIosMainCallbacksDisplayLink *globalDisplayLink;
|
||||
[self.displayLink invalidate];
|
||||
self.displayLink = nil;
|
||||
globalDisplayLink = nil;
|
||||
SDL_QuitMainCallbacks();
|
||||
SDL_QuitMainCallbacks(rc);
|
||||
SDL_UpdateLifecycleObserver();
|
||||
exit((rc == SDL_APP_FAILURE) ? 1 : 0);
|
||||
}
|
||||
@@ -66,16 +66,18 @@ static SDLIosMainCallbacksDisplayLink *globalDisplayLink;
|
||||
// When we return from here, we're living in the RunLoop, and a CADisplayLink is firing regularly for us.
|
||||
int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
||||
{
|
||||
const SDL_AppResult rc = SDL_InitMainCallbacks(argc, argv, appinit, appiter, appevent, appquit);
|
||||
SDL_AppResult rc = SDL_InitMainCallbacks(argc, argv, appinit, appiter, appevent, appquit);
|
||||
if (rc == SDL_APP_CONTINUE) {
|
||||
globalDisplayLink = [[SDLIosMainCallbacksDisplayLink alloc] init:appiter quitfunc:appquit];
|
||||
if (globalDisplayLink != nil) {
|
||||
if (globalDisplayLink == nil) {
|
||||
rc = SDL_APP_FAILURE;
|
||||
} else {
|
||||
return 0; // this will fall all the way out of SDL_main, where UIApplicationMain will keep running the RunLoop.
|
||||
}
|
||||
}
|
||||
|
||||
// appinit requested quit, just bounce out now.
|
||||
SDL_QuitMainCallbacks();
|
||||
SDL_QuitMainCallbacks(rc);
|
||||
exit((rc == SDL_APP_FAILURE) ? 1 : 0);
|
||||
|
||||
return 1; // just in case.
|
||||
|
Reference in New Issue
Block a user