this should fix the double free that happens when closing the sdl window on ios (untested)
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.h Tue Aug 23 09:23:45 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.h Tue Aug 23 10:07:40 2011 +0200
@@ -25,6 +25,7 @@
@class MapConfigViewController;
@class TeamConfigViewController;
@class SchemeWeaponConfigViewController;
+@class GameInterfaceBridge;
@interface GameConfigViewController : UIViewController {
UIView *imgContainer;
@@ -33,6 +34,7 @@
MapConfigViewController *mapConfigViewController;
TeamConfigViewController *teamConfigViewController;
SchemeWeaponConfigViewController *schemeWeaponConfigViewController;
+ GameInterfaceBridge *interfaceBridge;
}
@property (retain) UIView *imgContainer;
@@ -40,6 +42,7 @@
@property (nonatomic,retain) MapConfigViewController *mapConfigViewController;
@property (nonatomic,retain) TeamConfigViewController *teamConfigViewController;
@property (nonatomic,retain) SchemeWeaponConfigViewController *schemeWeaponConfigViewController;
+@property (nonatomic,retain) GameInterfaceBridge *interfaceBridge;
-(IBAction) buttonPressed:(id) sender;
-(IBAction) segmentPressed:(id) sender;
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Tue Aug 23 09:23:45 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Tue Aug 23 10:07:40 2011 +0200
@@ -30,7 +30,7 @@
#import "PascalImports.h"
@implementation GameConfigViewController
-@synthesize imgContainer, helpPage, mapConfigViewController, teamConfigViewController, schemeWeaponConfigViewController;
+@synthesize imgContainer, helpPage, mapConfigViewController, teamConfigViewController, schemeWeaponConfigViewController, interfaceBridge;
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
@@ -230,11 +230,12 @@
script,@"mission_command",
nil];
- GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self];
-
- [bridge startLocalGame:gameDictionary];
-
- [bridge release];
+ if (self.interfaceBridge == nil) {
+ GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self];
+ self.interfaceBridge = bridge;
+ [bridge release];
+ }
+ [self.interfaceBridge startLocalGame:gameDictionary];
}
-(void) loadNiceHogs {
@@ -377,12 +378,14 @@
self.mapConfigViewController = nil;
self.imgContainer = nil;
+ self.interfaceBridge = nil;
MSG_MEMCLEAN();
[super didReceiveMemoryWarning];
}
-(void) viewDidUnload {
self.imgContainer = nil;
+ self.interfaceBridge = nil;
self.mapConfigViewController = nil;
self.teamConfigViewController = nil;
self.schemeWeaponConfigViewController = nil;
@@ -393,6 +396,7 @@
-(void) dealloc {
releaseAndNil(imgContainer);
+ releaseAndNil(interfaceBridge);
releaseAndNil(mapConfigViewController);
releaseAndNil(teamConfigViewController);
releaseAndNil(schemeWeaponConfigViewController);
--- a/project_files/HedgewarsMobile/Classes/RestoreViewController.h Tue Aug 23 09:23:45 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/RestoreViewController.h Tue Aug 23 10:07:40 2011 +0200
@@ -21,10 +21,13 @@
#import <UIKit/UIKit.h>
+@class GameInterfaceBridge;
@interface RestoreViewController : UIViewController {
+ GameInterfaceBridge *interfaceBridge;
+}
-}
+@property (nonatomic,retain) GameInterfaceBridge *interfaceBridge;
-(IBAction) buttonReleased:(id) sender;
--- 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];
}
--- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.h Tue Aug 23 09:23:45 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.h Tue Aug 23 10:07:40 2011 +0200
@@ -22,14 +22,18 @@
#import <UIKit/UIKit.h>
#import "EditableCellView.h"
+@class GameInterfaceBridge;
+
@interface SavedGamesViewController : UIViewController <UITableViewDelegate, UITableViewDataSource,
EditableCellViewDelegate, UIActionSheetDelegate> {
UITableView *tableView;
NSMutableArray *listOfSavegames;
+ GameInterfaceBridge *interfaceBridge;
}
@property (nonatomic,retain) IBOutlet UITableView *tableView;
@property (nonatomic,retain) NSMutableArray *listOfSavegames;
+@property (nonatomic,retain) GameInterfaceBridge *interfaceBridge;
-(IBAction) buttonPressed:(id) sender;
-(IBAction) toggleEdit:(id) sender;
--- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Tue Aug 23 09:23:45 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Tue Aug 23 10:07:40 2011 +0200
@@ -24,7 +24,7 @@
#import "CommodityFunctions.h"
@implementation SavedGamesViewController
-@synthesize tableView, listOfSavegames;
+@synthesize tableView, listOfSavegames, interfaceBridge;
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
return rotationManager(interfaceOrientation);
@@ -209,13 +209,15 @@
[(EditableCellView *)[self.tableView cellForRowAtIndexPath:indexPath] save:nil];
- GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self];
+ if (self.interfaceBridge == nil) {
+ GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self];
+ self.interfaceBridge = bridge;
+ [bridge release];
+ }
NSString *filePath = [[NSString alloc] initWithFormat:@"%@/%@",SAVES_DIRECTORY(),[self.listOfSavegames objectAtIndex:[indexPath row]]];
- [bridge startSaveGame:filePath];
+ [self.interfaceBridge startSaveGame:filePath];
[filePath release];
-
- [bridge release];
}
#pragma mark -
@@ -238,6 +240,7 @@
#pragma mark Memory Management
-(void) didReceiveMemoryWarning {
self.listOfSavegames = nil;
+ self.interfaceBridge = nil;
MSG_MEMCLEAN();
[super didReceiveMemoryWarning];
}
@@ -245,6 +248,7 @@
-(void) viewDidUnload {
self.tableView = nil;
self.listOfSavegames = nil;
+ self.interfaceBridge = nil;
MSG_DIDUNLOAD();
[super viewDidUnload];
}
@@ -252,6 +256,7 @@
-(void) dealloc {
releaseAndNil(tableView);
releaseAndNil(listOfSavegames);
+ releaseAndNil(interfaceBridge);
[super dealloc];
}