- Release Objective-C objects (since I found out the garbage collector is opt-in).

SVN r2441 (trunk)
This commit is contained in:
Braden Obrzut 2010-07-18 09:23:33 +00:00
parent 1cf12693ba
commit 921c950bad

View file

@ -53,6 +53,7 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" };
NSMutableArray *data; NSMutableArray *data;
} }
- (void)dealloc;
- (IWADTableData *)init:(WadStuff *) wads:(int) numwads; - (IWADTableData *)init:(WadStuff *) wads:(int) numwads;
- (int)numberOfRowsInTableView:(NSTableView *)aTableView; - (int)numberOfRowsInTableView:(NSTableView *)aTableView;
@ -61,6 +62,13 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" };
@implementation IWADTableData @implementation IWADTableData
- (void)dealloc
{
[data release];
[super dealloc];
}
- (IWADTableData *)init:(WadStuff *) wads:(int) numwads - (IWADTableData *)init:(WadStuff *) wads:(int) numwads
{ {
data = [[NSMutableArray alloc] initWithCapacity:numwads]; data = [[NSMutableArray alloc] initWithCapacity:numwads];
@ -76,6 +84,7 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" };
[record setObject:[NSString stringWithCString:filename] forKey:[NSString stringWithCString:tableHeaders[COLUMN_IWAD]]]; [record setObject:[NSString stringWithCString:filename] forKey:[NSString stringWithCString:tableHeaders[COLUMN_IWAD]]];
[record setObject:[NSString stringWithCString:IWADInfos[wads[i].Type].Name] forKey:[NSString stringWithCString:tableHeaders[COLUMN_GAME]]]; [record setObject:[NSString stringWithCString:IWADInfos[wads[i].Type].Name] forKey:[NSString stringWithCString:tableHeaders[COLUMN_GAME]]];
[data addObject:record]; [data addObject:record];
[record release];
} }
return self; return self;
@ -96,7 +105,7 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" };
@end @end
// So we can listen for button actions and such we need to have an Obj-C class. // So we can listen for button actions and such we need to have an Obj-C class.
@interface IWADPicker : NSResponder @interface IWADPicker : NSObject
{ {
NSApplication *app; NSApplication *app;
NSWindow *window; NSWindow *window;
@ -146,6 +155,7 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" };
NSTextField *description = [[NSTextField alloc] initWithFrame:NSMakeRect(22, 379, 372, 50)]; NSTextField *description = [[NSTextField alloc] initWithFrame:NSMakeRect(22, 379, 372, 50)];
[self makeLabel:description:"ZDoom found more than one IWAD\nSelect from the list below to determine which one to use:"]; [self makeLabel:description:"ZDoom found more than one IWAD\nSelect from the list below to determine which one to use:"];
[[window contentView] addSubview:description]; [[window contentView] addSubview:description];
[description release];
// Commented out version would account for an additional parameters box. // Commented out version would account for an additional parameters box.
//NSScrollView *iwadScroller = [[NSScrollView alloc] initWithFrame:NSMakeRect(20, 103, 362, 288)]; //NSScrollView *iwadScroller = [[NSScrollView alloc] initWithFrame:NSMakeRect(20, 103, 362, 288)];
@ -161,14 +171,19 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" };
[column setEditable:NO]; [column setEditable:NO];
[column setResizingMask:NSTableColumnAutoresizingMask]; [column setResizingMask:NSTableColumnAutoresizingMask];
[iwadTable addTableColumn:column]; [iwadTable addTableColumn:column];
[column release];
} }
[iwadScroller setDocumentView:iwadTable]; [iwadScroller setDocumentView:iwadTable];
[iwadScroller setHasVerticalScroller:YES]; [iwadScroller setHasVerticalScroller:YES];
[iwadTable setDataSource:tableData]; [iwadTable setDataSource:tableData];
[iwadTable sizeToFit]; [iwadTable sizeToFit];
[iwadTable selectRowIndexes:[[NSIndexSet alloc] initWithIndex:defaultiwad] byExtendingSelection:NO]; NSIndexSet *selection = [[NSIndexSet alloc] initWithIndex:defaultiwad];
[iwadTable selectRowIndexes:selection byExtendingSelection:NO];
[selection release];
[iwadTable scrollRowToVisible:defaultiwad]; [iwadTable scrollRowToVisible:defaultiwad];
[[window contentView] addSubview:iwadScroller]; [[window contentView] addSubview:iwadScroller];
[iwadTable release];
[iwadScroller release];
/*NSTextField *additionalParametersLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(17, 78, 144, 17)]; /*NSTextField *additionalParametersLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(17, 78, 144, 17)];
[self makeLabel:additionalParametersLabel:"Additional Parameters"]; [self makeLabel:additionalParametersLabel:"Additional Parameters"];
@ -200,6 +215,10 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" };
[window center]; [window center];
[app runModalForWindow:window]; [app runModalForWindow:window];
[window release];
[okButton release];
[cancelButton release];
return cancelled ? -1 : [iwadTable selectedRow]; return cancelled ? -1 : [iwadTable selectedRow];
} }
@ -208,5 +227,8 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" };
// Simple wrapper so we can call this from outside. // Simple wrapper so we can call this from outside.
int I_PickIWad_Cocoa (WadStuff *wads, int numwads, bool showwin, int defaultiwad) int I_PickIWad_Cocoa (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
{ {
return [[IWADPicker alloc] pickIWad:wads:numwads:showwin:defaultiwad]; IWADPicker *picker = [IWADPicker alloc];
int ret = [picker pickIWad:wads:numwads:showwin:defaultiwad];
[picker release];
return ret;
} }