Fixed bug #847
authorSam Lantinga
Mon, 02 Nov 2009 07:55:42 +0000
changeset 3422ec4db979dddb
parent 3421 7bc83a9e09fd
child 3423 45ad54b4d9d6
Fixed bug #847

Roger Willcocks 2009-10-25 08:45:37 PDT

appDidFinishLaunching is triggered before all the setup's complete. The easiest
fix is to arrange for another event to be sent when it's really ready, and run
SDL_main from there. Ref.
http://blog.rightsprite.com/2008/11/iphone-applicationdidfinishlaunching.html

SDL-1.3.0-4563/src/video/uikit/SDL_uikitappdelegate.m:



- (void)postFinishLaunch {

/* 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, passing the return status from the user's application */
exit(exit_status);

}

- (void)applicationDidFinishLaunching:(UIApplication *)application {

/* Set working directory to resource path */
[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle
mainBundle] resourcePath]];

[self performSelector:@selector(postFinishLaunch) withObject:nil
afterDelay:0.0];
src/video/uikit/SDL_uikitappdelegate.m
     1.1 --- a/src/video/uikit/SDL_uikitappdelegate.m	Fri Oct 30 05:02:47 2009 +0000
     1.2 +++ b/src/video/uikit/SDL_uikitappdelegate.m	Mon Nov 02 07:55:42 2009 +0000
     1.3 @@ -71,11 +71,8 @@
     1.4  	return self;
     1.5  }
     1.6  
     1.7 -- (void)applicationDidFinishLaunching:(UIApplication *)application {
     1.8 -			
     1.9 -	/* Set working directory to resource path */
    1.10 -	[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
    1.11 -	
    1.12 +- (void)postFinishLaunch {
    1.13 +
    1.14  	/* run the user's application, passing argc and argv */
    1.15  	int exit_status = SDL_main(forward_argc, forward_argv);
    1.16  	
    1.17 @@ -88,7 +85,15 @@
    1.18  		
    1.19  	/* exit, passing the return status from the user's application */
    1.20  	exit(exit_status);
    1.21 -		
    1.22 +}
    1.23 +
    1.24 +- (void)applicationDidFinishLaunching:(UIApplication *)application {
    1.25 +			
    1.26 +	/* Set working directory to resource path */
    1.27 +	[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
    1.28 +	
    1.29 +	[self performSelector:@selector(postFinishLaunch) withObject:nil
    1.30 +afterDelay:0.0];
    1.31  }
    1.32  
    1.33  - (void)applicationWillTerminate:(UIApplication *)application {