From 3e5038fa11598fde4b424008888dad20a048c755 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 9 Nov 2009 14:24:21 +0000 Subject: - Wrap SPF restoreSession: call in a task, using the new nested task support to fix issue #452 --- Source/TableDocument.m | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Source/TableDocument.m b/Source/TableDocument.m index d17ee1e2..a8a71e8b 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -500,11 +500,15 @@ */ - (void)restoreSession { + NSAutoreleasePool *taskPool = [[NSAutoreleasePool alloc] init]; // Check and set the table NSArray *tables = [tablesListInstance tables]; - if([tables indexOfObject:[spfSession objectForKey:@"table"]] == NSNotFound) return; + if([tables indexOfObject:[spfSession objectForKey:@"table"]] == NSNotFound) { + [taskPool drain]; + return; + } // Restore toolbar setting if([spfSession objectForKey:@"isToolbarVisible"]) @@ -559,6 +563,9 @@ [spfSession release]; spfSession = nil; + // End the task + [self endTask]; + [taskPool drain]; } /** @@ -691,7 +698,14 @@ [tableWindow makeFirstResponder:[tablesListInstance valueForKeyPath:@"tablesListView"]]; if(spfSession != nil) { - [self restoreSession]; + + // Start a task to restore the session details + [self startTaskWithDescription:NSLocalizedString(@"Restoring session...", @"Restoring session task description")]; + if ([NSThread isMainThread]) { + [NSThread detachNewThreadSelector:@selector(restoreSession) toTarget:self withObject:nil]; + } else { + [self restoreSession]; + } } else { switch ([prefs integerForKey:SPDefaultViewMode] > 0 ? [prefs integerForKey:SPDefaultViewMode] : [prefs integerForKey:SPLastViewMode]) { default: -- cgit v1.2.3