From 97fd0957cef34210caece133fee16a370e5b9f5d Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 4 Nov 2009 23:31:24 +0000 Subject: - Use threaded loads when switching view tabs for unloaded tables --- Source/TablesList.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/TablesList.m b/Source/TablesList.m index 9264b9f1..c2dcd4a7 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -1404,10 +1404,18 @@ #pragma mark TabView delegate methods /** - * Loads structure or source if tab selected the first time + * Loads structure or source if tab selected the first time, + * using a threaded load. */ - (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem { + [tableDocumentInstance startTaskWithDescription:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), selectedTableName]]; + [NSThread detachNewThreadSelector:@selector(loadTabTask:) toTarget:self withObject:tabViewItem]; +} +- (void)loadTabTask:(NSTabViewItem *)tabViewItem +{ + NSAutoreleasePool *tabLoadPool = [[NSAutoreleasePool alloc] init]; + if ( [tablesListView numberOfSelectedRows] == 1 && ([self tableType] == SP_TABLETYPE_TABLE || [self tableType] == SP_TABLETYPE_VIEW) ) { @@ -1430,6 +1438,9 @@ [tableSourceInstance loadTable:nil]; [tableContentInstance loadTable:nil]; } + + [tableDocumentInstance endTask]; + [tabLoadPool drain]; } /** -- cgit v1.2.3