Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main()
authorKees Bakker <kees@ijzerbout.nl>
Tue, 27 Sep 2011 23:49:24 +0200
changeset 6006889d89332de4
parent 6005 f5327bae25cb
child 6007 0e647f56751d
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
     1.1 --- a/src/video/uikit/SDL_uikitappdelegate.m	Tue Sep 27 23:40:21 2011 +0200
     1.2 +++ b/src/video/uikit/SDL_uikitappdelegate.m	Tue Sep 27 23:49:24 2011 +0200
     1.3 @@ -36,6 +36,7 @@
     1.4  extern int SDL_main(int argc, char *argv[]);
     1.5  static int forward_argc;
     1.6  static char **forward_argv;
     1.7 +static int exit_status;
     1.8  
     1.9  int main(int argc, char **argv)
    1.10  {
    1.11 @@ -54,8 +55,14 @@
    1.12      /* Give over control to run loop, SDLUIKitDelegate will handle most things from here */
    1.13      UIApplicationMain(argc, argv, NULL, [SDLUIKitDelegate getAppDelegateClassName]);
    1.14  
    1.15 +    /* free the memory we used to hold copies of argc and argv */
    1.16 +    for (i = 0; i < forward_argc; i++) {
    1.17 +        free(forward_argv[i]);
    1.18 +    }
    1.19 +    free(forward_argv);
    1.20 +
    1.21      [pool release];
    1.22 -    return 0;
    1.23 +    return exit_status;
    1.24  }
    1.25  
    1.26  static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, const char *newValue)
    1.27 @@ -95,17 +102,10 @@
    1.28      SDL_RegisterHintChangedCb(SDL_HINT_IDLE_TIMER_DISABLED, &SDL_IdleTimerDisabledChanged);
    1.29  
    1.30      /* run the user's application, passing argc and argv */
    1.31 -    int exit_status = SDL_main(forward_argc, forward_argv);
    1.32 -
    1.33 -    /* free the memory we used to hold copies of argc and argv */
    1.34 -    int i;
    1.35 -    for (i = 0; i < forward_argc; i++) {
    1.36 -        free(forward_argv[i]);
    1.37 -    }
    1.38 -    free(forward_argv);
    1.39 +    exit_status = SDL_main(forward_argc, forward_argv);
    1.40  
    1.41      /* exit, passing the return status from the user's application */
    1.42 -    exit(exit_status);
    1.43 +    // exit(exit_status);
    1.44  }
    1.45  
    1.46  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions