project_files/HedgewarsMobile/Classes/RestoreViewController.m
changeset 5666 cc79eb30346e
parent 5220 76a2246f18f0
child 5668 36c1d1b789b8
--- a/project_files/HedgewarsMobile/Classes/RestoreViewController.m	Tue Aug 23 09:23:45 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/RestoreViewController.m	Tue Aug 23 10:07:40 2011 +0200
@@ -23,7 +23,7 @@
 #import "GameInterfaceBridge.h"
 
 @implementation RestoreViewController
-
+@synthesize interfaceBridge;
 
 // Override to allow orientations other than the default portrait orientation.
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
@@ -36,10 +36,13 @@
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 
     if (theButton.tag != 0) {
-        GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self.parentViewController];
+        if (self.interfaceBridge == nil) {
+            GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self];
+            self.interfaceBridge = bridge;
+            [bridge release];
+        }
         [self.parentViewController dismissModalViewControllerAnimated:NO];
-        [bridge startSaveGame:[defaults objectForKey:@"savedGamePath"]];
-        [bridge release];
+        [self.interfaceBridge startSaveGame:[defaults objectForKey:@"savedGamePath"]];
     } else {
         [defaults setObject:@"" forKey:@"savedGamePath"];
         [defaults synchronize];
@@ -47,10 +50,6 @@
     }
 }
 
--(void) didReceiveMemoryWarning {
-    [super didReceiveMemoryWarning];
-}
-
 -(void) viewDidLoad {
     NSString *imgName;
     if (IS_IPAD())
@@ -63,11 +62,18 @@
     [super viewDidLoad];
 }
 
+-(void) didReceiveMemoryWarning {
+    self.interfaceBridge = nil;
+    [super didReceiveMemoryWarning];
+}
+
 -(void) viewDidUnload {
+    self.interfaceBridge = nil;
     [super viewDidUnload];
 }
 
 -(void) dealloc {
+    releaseAndNil(interfaceBridge);
     [super dealloc];
 }