aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableContent.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-02-23 01:26:33 +0000
committerrowanbeentje <rowan@beent.je>2010-02-23 01:26:33 +0000
commita24e9c697049bacb587835153e2ebb4764fff008 (patch)
treebab464b0eb1c44bb35ed745d41ba2e46beb9350d /Source/TableContent.m
parentc11169058366ca679789bc82cf1b3ca8ed496967 (diff)
downloadsequelpro-a24e9c697049bacb587835153e2ebb4764fff008.tar.gz
sequelpro-a24e9c697049bacb587835153e2ebb4764fff008.tar.bz2
sequelpro-a24e9c697049bacb587835153e2ebb4764fff008.zip
Fix Issue #574 (foreign key links not working after first use):
- Move foreign key reference loading into it's own task and set state modification markers to allow it to override the table state history - Rename modifyingHistoryState to modifyingState now the usge has broadened slightly
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r--Source/TableContent.m34
1 files changed, 29 insertions, 5 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index a0e2d610..3a736a90 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -1528,17 +1528,33 @@
if ([tableDocumentInstance isWorking]) return;
if ([theArrowCell getClickedColumn] == NSNotFound || [theArrowCell getClickedRow] == NSNotFound) return;
+
+ // Check whether a save of the current row is required.
+ if ( ![self saveRowOnDeselect] ) return;
+
+ // If on the main thread, fire up a thread to perform the load while keeping the modification flag
+ [tableDocumentInstance startTaskWithDescription:NSLocalizedString(@"Loading reference...", @"Loading referece task string")];
+ if ([NSThread isMainThread]) {
+ [NSThread detachNewThreadSelector:@selector(clickLinkArrowTask:) toTarget:self withObject:theArrowCell];
+ } else {
+ [self clickLinkArrowTask:theArrowCell];
+ }
+}
+- (void)clickLinkArrowTask:(SPTextAndLinkCell *)theArrowCell
+{
+ NSAutoreleasePool *linkPool = [[NSAutoreleasePool alloc] init];
NSUInteger dataColumnIndex = [[[[tableContentView tableColumns] objectAtIndex:[theArrowCell getClickedColumn]] identifier] integerValue];
// Ensure the clicked cell has foreign key details available
NSDictionary *refDictionary = [[dataColumns objectAtIndex:dataColumnIndex] objectForKey:@"foreignkeyreference"];
- if (!refDictionary) return;
-
- // Check whether a save of the current row is required.
- if ( ![self saveRowOnDeselect] ) return;
+ if (!refDictionary) {
+ [linkPool release];
+ return;
+ }
- // Save existing scroll position and details
+ // Save existing scroll position and details and mark that state is being modified
[spHistoryControllerInstance updateHistoryEntries];
+ [spHistoryControllerInstance setModifyingState:YES];
NSString *targetFilterValue = [tableValues cellDataAtRow:[theArrowCell getClickedRow] column:dataColumnIndex];
@@ -1569,6 +1585,14 @@
[self setFiltersToRestore:nil];
}
}
+
+ // End state and ensure a new history entry
+ [spHistoryControllerInstance setModifyingState:NO];
+ [spHistoryControllerInstance updateHistoryEntries];
+
+ // Empty the loading pool and exit the thread
+ [tableDocumentInstance endTask];
+ [linkPool drain];
}
/**