ios: fix a couple of bad memory management (unrelated to the crash at the end of each game)
authorkoda
Sun, 28 Aug 2011 11:38:24 +0200
changeset 5696 972bf04d4a79
parent 5695 f1015857deb8
child 5697 e6630feefe88
ios: fix a couple of bad memory management (unrelated to the crash at the end of each game) sdl13: fixed compilation
hedgewars/uStore.pas
project_files/HedgewarsMobile/Classes/GameInterfaceBridge.h
project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
--- a/hedgewars/uStore.pas	Sat Aug 27 17:53:35 2011 -0400
+++ b/hedgewars/uStore.pas	Sun Aug 28 11:38:24 2011 +0200
@@ -1006,7 +1006,7 @@
     flags:= flags or SDL_WINDOW_BORDERLESS or SDL_WINDOW_RESIZABLE;
 {$ENDIF}
 
-    if cFullScreen then SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cOrigScreenWidth, cOrigScreenHeight, flags);
+    if cFullScreen then SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cOrigScreenWidth, cOrigScreenHeight, flags or SDL_WINDOW_FULLSCREEN)
     else SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags);
     SDLTry(SDLwindow <> nil, true);
 {$ELSE}
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.h	Sat Aug 27 17:53:35 2011 -0400
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.h	Sun Aug 28 11:38:24 2011 +0200
@@ -38,7 +38,7 @@
     TGameType gameType;
 }
 
-@property (nonatomic,retain) UIViewController *parentController;
+@property (assign) UIViewController *parentController;
 @property (nonatomic,retain) NSString *savePath;
 
 @property (nonatomic,retain) OverlayViewController *overlayController;
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Sat Aug 27 17:53:35 2011 -0400
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Sun Aug 28 11:38:24 2011 +0200
@@ -45,7 +45,6 @@
 }
 
 -(void) dealloc {
-    releaseAndNil(parentController);
     releaseAndNil(engineProtocol);
     releaseAndNil(savePath);
     releaseAndNil(overlayController);
@@ -178,10 +177,6 @@
     // warn our host that it's going to be visible again
     [self.parentController viewWillAppear:YES];
 
-    // release the network manager and the savepath as they are not needed anymore
-    releaseAndNil(self.engineProtocol);
-    releaseAndNil(self.savePath);
-
     if ([[userDefaults objectForKey:@"music"] boolValue])
         [HedgewarsAppDelegate playBackgroundMusic];
 }
@@ -192,8 +187,10 @@
 
     NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
     [outputFormatter setDateFormat:@"yyyy-MM-dd '@' HH.mm"];
-    self.savePath = [[NSString alloc] initWithFormat:@"%@%@.hws",SAVES_DIRECTORY(),[outputFormatter stringFromDate:[NSDate date]]];
+    NSString *path = [[NSString alloc] initWithFormat:@"%@%@.hws",SAVES_DIRECTORY(),[outputFormatter stringFromDate:[NSDate date]]];
     [outputFormatter release];
+    self.savePath = path;
+    [path release];
 
     // in the rare case in which a savefile with the same name exists the older one must be removed (or it gets corrupted)
     if ([[NSFileManager defaultManager] fileExistsAtPath:self.savePath])
@@ -206,7 +203,7 @@
 // set up variables for a save game
 -(void) startSaveGame:(NSString *)atPath {
     self.gameType = gtSave;
-    self.savePath = [atPath retain];
+    self.savePath = atPath;
 
     [self.engineProtocol spawnThread:self.savePath];
     [self prepareEngineLaunch];