From 455c5326835d811b55d12b3ac8c0373608825b8d Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 28 Jul 2009 23:58:12 +0000 Subject: - Fix "endSheet:returnCode: requires a non-nil sheet" log lines during imports - Enable threaded animation for import/export progress bars as it has minimal overhead and looks nicer - Fix exceptions caused by tablesList drawing during imports --- Source/TableDump.m | 18 ++++++------------ Source/TablesList.m | 6 ++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/TableDump.m b/Source/TableDump.m index 34ffe262..b4ee6660 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -86,12 +86,11 @@ [exportMultipleXMLTableView reloadData]; } -- (IBAction)closeSheet:(id)sender /* - ends the modal session + * Common method for ending modal sessions */ +- (IBAction)closeSheet:(id)sender { - [NSApp endSheet:exportWindow]; [NSApp stopModalWithCode:[sender tag]]; } @@ -473,7 +472,6 @@ unsigned long queryCount = [queries count]; [singleProgressBar stopAnimation:self]; - [singleProgressBar setUsesThreadedAnimation:NO]; [singleProgressBar setIndeterminate:NO]; [singleProgressTitle setStringValue:NSLocalizedString(@"Importing SQL", @"text showing that the application is importing SQL")]; [singleProgressText setStringValue:[NSString stringWithFormat:NSLocalizedString(@"Executing %d statements...", @"text showing that app is executing x statements"), queryCount]]; @@ -524,7 +522,6 @@ contextInfo:nil]; [NSApp runModalForWindow:errorsSheet]; - [NSApp endSheet:errorsSheet]; [errorsSheet orderOut:nil]; } @@ -633,7 +630,6 @@ contextInfo:nil]; code = [NSApp runModalForWindow:fieldMappingSheet]; - [NSApp endSheet:fieldMappingSheet]; [fieldMappingSheet orderOut:nil]; @@ -652,6 +648,7 @@ didEndSelector:nil contextInfo:nil]; + [singleProgressBar setUsesThreadedAnimation:NO]; [singleProgressSheet makeKeyWindow]; [singleProgressText setStringValue:NSLocalizedString(@"Creating rows...", @"text showing that app is importing rows from CSV")]; [singleProgressText displayIfNeeded]; @@ -724,8 +721,7 @@ didEndSelector:nil contextInfo:nil]; - [NSApp runModalForWindow:errorsSheet]; - + [NSApp runModalForWindow:errorsSheet]; [NSApp endSheet:errorsSheet]; [errorsSheet orderOut:nil]; } @@ -983,7 +979,6 @@ [singleProgressText setStringValue:[NSString stringWithFormat:NSLocalizedString(@"Table %i of %i (%@): Dumping...", @"text showing that app is writing data for table dump"), (i+1), [selectedTables count], tableName]]; [singleProgressText displayIfNeeded]; [singleProgressBar stopAnimation:self]; - [singleProgressBar setUsesThreadedAnimation:NO]; [singleProgressBar setIndeterminate:NO]; [singleProgressBar setDoubleValue:0]; [singleProgressBar displayIfNeeded]; @@ -1138,7 +1133,6 @@ modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; [NSApp runModalForWindow:errorsSheet]; - [NSApp endSheet:errorsSheet]; [errorsSheet orderOut:nil]; } @@ -1347,6 +1341,7 @@ progressBarWidth = (int)[singleProgressBar bounds].size.width; lastProgressValue = 0; [singleProgressBar setDoubleValue:0]; + [singleProgressBar setUsesThreadedAnimation:YES]; [singleProgressBar displayIfNeeded]; if ( !silently ) { @@ -1983,8 +1978,7 @@ [NSApp beginSheet:errorsSheet modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; - [NSApp runModalForWindow:errorsSheet]; - + [NSApp runModalForWindow:errorsSheet]; [NSApp endSheet:errorsSheet]; [errorsSheet orderOut:nil]; } diff --git a/Source/TablesList.m b/Source/TablesList.m index 947c2f41..f3c39d60 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -1506,6 +1506,12 @@ */ - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { + + // During imports the table view sometimes appears to request items beyond the end of the array. + // Using a hinted noteNumberOfRowsChanged after dropping tables fixes this but then seems to stick + // even after override, so check here for the time being and display empty rows during import. + if (rowIndex >= [filteredTables count]) return @""; + return [filteredTables objectAtIndex:rowIndex]; } -- cgit v1.2.3