From eb10ee0dd4759e18ed1aee8b119d6e2bafeba8ef Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 13 Mar 2010 21:38:30 +0000 Subject: - Fix an exception when following a foreign key relationship to a null value in another table (this addresses http://log.sequelpro.com/view/53 ) - Fix filtering within the same table when following foreign key relationships --- Source/TableContent.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'Source') diff --git a/Source/TableContent.m b/Source/TableContent.m index f41df80a..793883f8 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1556,6 +1556,7 @@ { NSAutoreleasePool *linkPool = [[NSAutoreleasePool alloc] init]; NSUInteger dataColumnIndex = [[[[tableContentView tableColumns] objectAtIndex:[theArrowCell getClickedColumn]] identifier] integerValue]; + BOOL tableFilterRequired = NO; // Ensure the clicked cell has foreign key details available NSDictionary *refDictionary = [[dataColumns objectAtIndex:dataColumnIndex] objectForKey:@"foreignkeyreference"]; @@ -1579,8 +1580,7 @@ } else { [argumentField setStringValue:targetFilterValue]; } - [self filterTable:self]; - + tableFilterRequired = YES; } else { // Store the filter details to use when loading the target table @@ -1602,8 +1602,14 @@ [spHistoryControllerInstance setModifyingState:NO]; [spHistoryControllerInstance updateHistoryEntries]; - // Empty the loading pool and exit the thread + // End the task [tableDocumentInstance endTask]; + + // If the same table is the target, trigger a filter task on the main thread + if (tableFilterRequired) + [self performSelectorOnMainThread:@selector(filterTable:) withObject:self waitUntilDone:NO]; + + // Empty the loading pool and exit the thread [linkPool drain]; } @@ -2525,7 +2531,7 @@ if ([filterSettings objectForKey:@"secondBetweenField"]) secondBetweenValueToRestore = [[NSString alloc] initWithString:[filterSettings objectForKey:@"secondBetweenField"]]; } else { - if ([filterSettings objectForKey:@"filterValue"]) + if ([filterSettings objectForKey:@"filterValue"] && ![[filterSettings objectForKey:@"filterValue"] isNSNull]) filterValueToRestore = [[NSString alloc] initWithString:[filterSettings objectForKey:@"filterValue"]]; } } -- cgit v1.2.3