From 898a298bd80045a4243f6f5eacbcd71b8558cb5a Mon Sep 17 00:00:00 2001 From: Kees Bakker Date: Tue, 27 Sep 2011 23:49:24 +0200 Subject: [PATCH] Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main() Also cleanup the stored argv in main() instead of postFinishLaunch. --- src/video/uikit/SDL_uikitappdelegate.m | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index 4042d7901..b62e37f90 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -36,6 +36,7 @@ extern int SDL_main(int argc, char *argv[]); static int forward_argc; static char **forward_argv; +static int exit_status; int main(int argc, char **argv) { @@ -54,8 +55,14 @@ int main(int argc, char **argv) /* Give over control to run loop, SDLUIKitDelegate will handle most things from here */ UIApplicationMain(argc, argv, NULL, [SDLUIKitDelegate getAppDelegateClassName]); + /* free the memory we used to hold copies of argc and argv */ + for (i = 0; i < forward_argc; i++) { + free(forward_argv[i]); + } + free(forward_argv); + [pool release]; - return 0; + return exit_status; } static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, const char *newValue) @@ -95,17 +102,10 @@ - (void)postFinishLaunch SDL_RegisterHintChangedCb(SDL_HINT_IDLE_TIMER_DISABLED, &SDL_IdleTimerDisabledChanged); /* run the user's application, passing argc and argv */ - int exit_status = SDL_main(forward_argc, forward_argv); - - /* free the memory we used to hold copies of argc and argv */ - int i; - for (i = 0; i < forward_argc; i++) { - free(forward_argv[i]); - } - free(forward_argv); + exit_status = SDL_main(forward_argc, forward_argv); /* exit, passing the return status from the user's application */ - exit(exit_status); + // exit(exit_status); } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions