- Fix for crash on loading SingleWeaponViewController in Settings ios-revival
authorantonc27 <antonc27@mail.ru>
Thu, 27 Aug 2015 23:21:07 +0200
branchios-revival
changeset 11141 01e8e5a6a8c1
parent 11140 3fbe54013b2b
child 11142 737ba45f533a
- Fix for crash on loading SingleWeaponViewController in Settings
hedgewars/uLocale.pas
project_files/HedgewarsMobile/Classes/PascalImports.h
project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m
--- a/hedgewars/uLocale.pas	Thu Aug 27 23:19:29 2015 +0200
+++ b/hedgewars/uLocale.pas	Thu Aug 27 23:21:07 2015 +0200
@@ -30,7 +30,7 @@
 function  GetEventString(e: TEventId): ansistring;
 
 {$IFDEF HWLIBRARY}
-procedure LoadLocaleWrapper(str: pchar); cdecl; export;
+procedure LoadLocaleWrapper(path: pchar; filename: pchar); cdecl; export;
 {$ENDIF}
 
 implementation
@@ -133,9 +133,17 @@
 end;
 
 {$IFDEF HWLIBRARY}
-procedure LoadLocaleWrapper(str: pchar); cdecl; export;
+procedure LoadLocaleWrapper(path: pchar; filename: pchar); cdecl; export;
 begin
-    LoadLocale(Strpas(str));
+    PathPrefix := Strpas(path);
+ 
+    uUtils.initModule(false);
+    uPhysFSLayer.initModule;
+ 
+    LoadLocale(Strpas(filename));
+ 
+    uPhysFSLayer.freeModule;
+    uUtils.freeModule;
 end;
 {$ENDIF}
 
--- a/project_files/HedgewarsMobile/Classes/PascalImports.h	Thu Aug 27 23:19:29 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/PascalImports.h	Thu Aug 27 23:21:07 2015 +0200
@@ -29,7 +29,7 @@
      */
 
     void RunEngine(const int argc, const char *argv[]);
-    void LoadLocaleWrapper(const char *filename);
+    void LoadLocaleWrapper(const char *filepath, const char *filename);
 
     void HW_versionInfo(int *protoNum, char **versionStr);
     void *HW_getSDLWindow(void);
--- a/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m	Thu Aug 27 23:19:29 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m	Thu Aug 27 23:21:07 2015 +0200
@@ -19,6 +19,10 @@
 
 #import "SingleWeaponViewController.h"
 
+@interface SingleWeaponViewController ()
+@property (nonatomic, retain) NSString *trPath;
+@property (nonatomic, retain) NSString *trFileName;
+@end
 
 @implementation SingleWeaponViewController
 @synthesize weaponName, description, ammoStoreImage;
@@ -32,9 +36,10 @@
 -(void) viewDidLoad {
     [super viewDidLoad];
 
-    NSString *trFilePath = [NSString stringWithFormat:@"%@/%@.txt",LOCALE_DIRECTORY(),[[NSLocale preferredLanguages] objectAtIndex:0]];
+    self.trPath = [NSString stringWithFormat:@"%@", LOCALE_DIRECTORY()];
+    self.trFileName = [NSString stringWithFormat:@"%@.txt", [[NSLocale preferredLanguages] firstObject]];
     // fill the data structure that we are going to read
-    LoadLocaleWrapper([trFilePath UTF8String]);
+    LoadLocaleWrapper([self.trPath UTF8String], [self.trFileName UTF8String]);
 
     quantity = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1));
     probability = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1));
@@ -261,6 +266,9 @@
 
 
 -(void) dealloc {
+    releaseAndNil(_trPath);
+    releaseAndNil(_trFileName);
+    
     releaseAndNil(weaponName);
     releaseAndNil(description);
     releaseAndNil(ammoStoreImage);