From b3065d6e706a5ddc7b0345c833ad125883cded82 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 6 Jul 2009 22:05:39 +0000 Subject: - Fixes crashes in the CSV Field Mapping sheet caused by multiple threads and autorelease pools (fixes Issue #326) - Reset the field mapping table list whenever it's about to be populated, fixing errors when performing imports into multi databases in the same session --- Source/TableDump.m | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Source') diff --git a/Source/TableDump.m b/Source/TableDump.m index 70a8f6e8..32e40700 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -384,7 +384,7 @@ //set up tableView currentRow = 0; - fieldMappingArray = nil; + if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil; [self setupFieldMappingArray]; [rowDownButton setEnabled:NO]; [rowUpButton setEnabled:([importArray count] > 1)]; @@ -588,6 +588,7 @@ int i; theResult = (CMMCPResult *) [mySQLConnection listTables]; if ([theResult numOfRows]) [theResult dataSeek:0]; + [fieldMappingPopup removeAllItems]; for ( i = 0 ; i < [theResult numOfRows] ; i++ ) { [fieldMappingPopup addItemWithTitle:NSArrayObjectAtIndex([theResult fetchRowAsArray], 0)]; } @@ -607,7 +608,7 @@ //set up tableView currentRow = 0; - fieldMappingArray = nil; + if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil; [self setupFieldMappingArray]; [rowDownButton setEnabled:NO]; [rowUpButton setEnabled:([importArray count] > 1)]; @@ -727,7 +728,7 @@ } //free arrays - fieldMappingArray = nil; + if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil; importArray = nil; } @@ -761,7 +762,7 @@ int i, value; if (!fieldMappingArray) { - fieldMappingArray = [NSMutableArray array]; + fieldMappingArray = [[NSMutableArray alloc] init]; for (i = 0; i < [[tableSourceInstance fieldNames] count]; i++) { if (i < [NSArrayObjectAtIndex(importArray, currentRow) count] && ![NSArrayObjectAtIndex(NSArrayObjectAtIndex(importArray, currentRow), i) isKindOfClass:[NSNull class]]) { @@ -2293,6 +2294,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn tables = [[NSMutableArray alloc] init]; fieldMappingButtonOptions = [[NSMutableArray alloc] init]; + fieldMappingArray = nil; return self; } @@ -2302,7 +2304,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [tables release]; [importArray release]; [fieldMappingButtonOptions release]; - [fieldMappingArray release]; + if (fieldMappingArray) [fieldMappingArray release]; [savePath release]; [openPath release]; [prefs release]; -- cgit v1.2.3