cleaning up how chat is handled on idevices
updated project to use updated libs
some leaks resolved (maybe)
--- a/hedgewars/PascalExports.pas Sat Feb 05 11:32:15 2011 +0300
+++ b/hedgewars/PascalExports.pas Sat Feb 05 15:45:44 2011 +0100
@@ -199,6 +199,11 @@
ParseCommand('forcequit', true);
end;
+function HW_getSDLWindow: pointer; cdecl; export;
+begin
+ exit( SDLwindow );
+end;
+
// cursor handling
procedure HW_setCursor(x,y: LongInt); cdecl; export;
begin
--- a/hedgewars/uChat.pas Sat Feb 05 11:32:15 2011 +0300
+++ b/hedgewars/uChat.pas Sat Feb 05 15:45:44 2011 +0100
@@ -65,9 +65,9 @@
color: TSDL_Color;
font: THWFont;
begin
-if cl.Tex <> nil then
- FreeTexture(cl.Tex);
-
+// these two lines lines crash when run multiple times?
+//if cl.Tex <> nil then
+// FreeTexture(cl.Tex);
cl.s:= str;
--- a/hedgewars/uStore.pas Sat Feb 05 11:32:15 2011 +0300
+++ b/hedgewars/uStore.pas Sat Feb 05 15:45:44 2011 +0100
@@ -343,8 +343,9 @@
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels);
TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
tmpsurf:= doSurfaceConversion(tmpsurf);
- if (NameTex <> nil) then
- FreeTexture(NameTex);
+ // these two lines lines crash when run multiple times?
+ //if (NameTex <> nil) then
+ // FreeTexture(NameTex);
NameTex:= Surface2Tex(tmpsurf, false);
SDL_FreeSurface(tmpsurf)
end;
@@ -354,8 +355,9 @@
begin
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
tmpsurf:= doSurfaceConversion(tmpsurf);
- if (CountTexz[i] <> nil) then
- FreeTexture(CountTexz[i]);
+ // these two lines lines crash when run multiple times?
+ //if (CountTexz[i] <> nil) then
+ // FreeTexture(CountTexz[i]);
CountTexz[i]:= Surface2Tex(tmpsurf, false);
SDL_FreeSurface(tmpsurf)
end;
--- a/project_files/HedgewarsMobile/Classes/InGameMenuViewController.h Sat Feb 05 11:32:15 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/InGameMenuViewController.h Sat Feb 05 15:45:44 2011 +0100
@@ -24,13 +24,11 @@
@interface InGameMenuViewController : UITableViewController <UIActionSheetDelegate> {
NSArray *menuList;
- SDL_Window *sdlwindow;
}
@property (nonatomic,retain) NSArray *menuList;
-(void) present;
-(void) dismiss;
--(void) removeChat;
@end
--- a/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m Sat Feb 05 11:32:15 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m Sat Feb 05 15:45:44 2011 +0100
@@ -48,31 +48,11 @@
self.menuList = array;
[array release];
- // save the sdl window (!= uikit window) for future reference
- SDL_VideoDevice *videoDevice = SDL_GetVideoDevice();
- if (videoDevice) {
- SDL_VideoDisplay *display = &videoDevice->displays[0];
- if (display)
- sdlwindow = display->windows;
- }
[super viewDidLoad];
}
--(void) viewWillAppear:(BOOL)animated {
- if (sdlwindow == NULL) {
- SDL_VideoDevice *_this = SDL_GetVideoDevice();
- if (_this) {
- SDL_VideoDisplay *display = &_this->displays[0];
- if (display)
- sdlwindow = display->windows;
- }
- }
- [super viewWillAppear:animated];
-}
-
-(void) viewDidUnload {
self.menuList = nil;
- sdlwindow = NULL;
MSG_DIDUNLOAD();
[super viewDidUnload];
}
@@ -106,7 +86,8 @@
[self.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.35];
- [self removeChat];
+ HW_chatEnd();
+ SDL_iPhoneKeyboardHide((SDL_Window *)HW_getSDLWindow());
}
#pragma mark -
@@ -127,7 +108,7 @@
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:cellIdentifier] autorelease];
}
- cell.textLabel.text = [menuList objectAtIndex:[indexPath row]];
+ cell.textLabel.text = [self.menuList objectAtIndex:[indexPath row]];
if (IS_IPAD())
cell.textLabel.textAlignment = UITextAlignmentCenter;
@@ -143,12 +124,8 @@
[[NSNotificationCenter defaultCenter] postNotificationName:@"show help ingame" object:nil];
break;
case 1:
- if (SDL_iPhoneKeyboardIsShown(sdlwindow))
- [self removeChat];
- else {
- HW_chat();
- SDL_iPhoneKeyboardShow(sdlwindow);
- }
+ HW_chat();
+ SDL_iPhoneKeyboardShow((SDL_Window *)HW_getSDLWindow());
break;
case 2:
// expand the view (and table) so that the actionsheet can be selected on the iPhone
@@ -177,13 +154,6 @@
[aTableView deselectRowAtIndexPath:indexPath animated:YES];
}
--(void) removeChat {
- if (SDL_iPhoneKeyboardIsShown(sdlwindow)) {
- SDL_iPhoneKeyboardHide(sdlwindow);
- HW_chatEnd();
- }
-}
-
#pragma mark -
#pragma mark actionSheet methods
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sat Feb 05 11:32:15 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sat Feb 05 15:45:44 2011 +0100
@@ -486,12 +486,10 @@
if (HW_isPaused())
HW_pauseToggle();
- if (IS_IPAD()) {
- [(InGameMenuViewController *)[[self popoverController] contentViewController] removeChat];
+ [self.popupMenu dismiss];
+ if (IS_IPAD())
[self.popoverController dismissPopoverAnimated:YES];
- } else {
- [self.popupMenu dismiss];
- }
+
[self buttonReleased:nil];
}
}
--- a/project_files/HedgewarsMobile/Classes/PascalImports.h Sat Feb 05 11:32:15 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/PascalImports.h Sat Feb 05 15:45:44 2011 +0100
@@ -68,6 +68,7 @@
void HW_pauseToggle(void);
BOOL HW_isPaused(void);
+ void *HW_getSDLWindow(void);
void HW_terminate(BOOL andCloseFrontend);
void HW_suspend(void);
void HW_resume(void);
--- a/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Sat Feb 05 11:32:15 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Sat Feb 05 15:45:44 2011 +0100
@@ -77,7 +77,9 @@
selectedTeamsCount = [self.listOfSelectedTeams count];
allTeamsCount = [self.listOfTeams count];
- self.cachedContentsOfDir = [[NSArray alloc] initWithArray:contentsOfDir copyItems:YES];
+ NSArray *contents = [[NSArray alloc] initWithArray:contentsOfDir copyItems:YES];
+ self.cachedContentsOfDir = contents;
+ [contents release];
}
[self.tableView reloadData];
}
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sat Feb 05 11:32:15 2011 +0300
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sat Feb 05 15:45:44 2011 +0100
@@ -715,42 +715,42 @@
isa = PBXContainerItemProxy;
containerPortal = 617988D3114AAA3900BA94A9 /* SDLiPhoneOS.xcodeproj */;
proxyType = 2;
- remoteGlobalIDString = FD6526630DE8FCCB002AD96B /* libSDLiPhoneOS.a */;
+ remoteGlobalIDString = FD6526630DE8FCCB002AD96B;
remoteInfo = StaticLibiPhoneOS;
};
61B7A54F12FA129F0051E14E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 617988D3114AAA3900BA94A9 /* SDLiPhoneOS.xcodeproj */;
proxyType = 2;
- remoteGlobalIDString = 006E982211955059001DE610 /* testsdl.app */;
+ remoteGlobalIDString = 006E982211955059001DE610;
remoteInfo = testsdl;
};
61B7A55712FA12AD0051E14E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 6127232E117DF752005B90CF /* SDL_image.xcodeproj */;
proxyType = 2;
- remoteGlobalIDString = BE1FA74107AF4C45004B6283 /* libSDL_image.a */;
+ remoteGlobalIDString = BE1FA74107AF4C45004B6283;
remoteInfo = "Static Library";
};
61B7A55F12FA12BF0051E14E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 6179898B114AB3FA00BA94A9 /* SDL_mixer.xcodeproj */;
proxyType = 2;
- remoteGlobalIDString = BE1FA95407AF96B2004B6283 /* libSDL_mixer.a */;
+ remoteGlobalIDString = BE1FA95407AF96B2004B6283;
remoteInfo = "Static Library";
};
61B7A56712FA12D00051E14E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 618E27B612A2C30700C20EF0 /* SDL_net.xcodeproj */;
proxyType = 2;
- remoteGlobalIDString = BE48FF6F07AFA9A900BB41DA /* libSDL_net.a */;
+ remoteGlobalIDString = BE48FF6F07AFA9A900BB41DA;
remoteInfo = "Static Library";
};
61B7A58F12FA13330051E14E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 61798A0B114AB65600BA94A9 /* SDL_ttf.xcodeproj */;
proxyType = 2;
- remoteGlobalIDString = BE48FD6E07AFA17000BB41DA /* libSDL_ttf.a */;
+ remoteGlobalIDString = BE48FD6E07AFA17000BB41DA;
remoteInfo = "Static Library";
};
928301590F10E41300CC5A3C /* PBXContainerItemProxy */ = {