cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m
changeset 3316 52f0482b043f
parent 3305 91074496d5c9
child 3317 198ec44b6d92
--- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Tue Apr 06 21:54:46 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Wed Apr 07 01:22:05 2010 +0000
@@ -35,7 +35,17 @@
 #undef main
 #endif
 
+#define VALGRIND "/opt/valgrind/bin/valgrind"
+
 int main (int argc, char *argv[]) {
+#ifdef VALGRIND_REXEC
+    // Using the valgrind build config, rexec ourself in valgrind
+    // from http://landonf.bikemonkey.org/code/iphone/iPhone_Simulator_Valgrind.20081224.html
+    if (argc < 2 || (argc >= 2 && strcmp(argv[1], "-valgrind") != 0)) {
+        execl(VALGRIND, VALGRIND, "--leak-check=full", "--show-reachable=yes", argv[0], "-valgrind", NULL);
+    }
+#endif
+
 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 	int retVal = UIApplicationMain(argc, argv, nil, @"SDLUIKitDelegate");
 	[pool release];
@@ -43,7 +53,7 @@
 }
 
 @implementation SDLUIKitDelegate
-@synthesize uiwindow, window, viewController, overlayController;
+@synthesize uiwindow, window, viewController;
 
 // convenience method
 +(SDLUIKitDelegate *)sharedAppDelegate {
@@ -56,7 +66,6 @@
         self.uiwindow = nil;
         self.window = NULL;
         self.viewController = nil;
-        self.overlayController = nil;
         isInGame = NO;
         return self;
     } else 
@@ -78,6 +87,7 @@
 	const char **gameArgs = [setup getSettings];
 	[setup release];
     
+    OverlayViewController *overlayController;
     // overlay with controls, become visible after 2 seconds
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
         overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController-iPad" bundle:nil];