From a4ee82dd8446b3374adac9f826118ab6c8a108a9 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 20 Mar 2010 22:07:49 +0000 Subject: - Add a new SPMainThreadTrampoline NSObject category, allowing all NSObjects to easily proxy commands onto the main thread with any number and type of arguments. - Use the new trampoline and other thread safety tweaks to hopefully address a number of what appear to be threading issues: http://log.sequelpro.com/view/20 http://log.sequelpro.com/view/32 http://log.sequelpro.com/view/41 http://log.sequelpro.com/view/42 http://log.sequelpro.com/view/55 http://log.sequelpro.com/view/64 http://log.sequelpro.com/view/65 http://log.sequelpro.com/view/66 --- Source/TableContent.m | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'Source/TableContent.m') diff --git a/Source/TableContent.m b/Source/TableContent.m index c5090573..abc6a8e7 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -51,6 +51,7 @@ #import "SPConstants.h" #import "SPDataStorage.h" #import "SPAlertSheets.h" +#import "SPMainThreadTrampoline.h" @implementation TableContent @@ -783,7 +784,7 @@ // If the clause has the placeholder $BINARY that placeholder will be replaced // by BINARY if the user pressed ⇧ while invoking 'Filter' otherwise it will // replaced by @"". - BOOL caseSensitive = (([[NSApp currentEvent] modifierFlags] + BOOL caseSensitive = (([[[NSApp onMainThread] currentEvent] modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask)) > 0); NSString *filterString; @@ -1001,7 +1002,7 @@ [countString appendFormat:NSLocalizedString(@"%@ %@ selected", @"text showing how many rows are selected"), [numberFormatter stringFromNumber:[NSNumber numberWithInteger:[tableContentView numberOfSelectedRows]]], rowString]; } - [countText setStringValue:countString]; + [[countText onMainThread] setStringValue:countString]; } #pragma mark - @@ -1028,7 +1029,7 @@ NSAutoreleasePool *reloadPool = [[NSAutoreleasePool alloc] init]; // Check whether a save of the current row is required. - if (![self saveRowOnDeselect]) return; + if (![[self onMainThread] saveRowOnDeselect]) return; // Save view details to restore safely if possible (except viewport, which will be // preserved automatically, and can then be scrolled as the table loads) @@ -1086,7 +1087,7 @@ NSAutoreleasePool *filterPool = [[NSAutoreleasePool alloc] init]; // Check whether a save of the current row is required. - if (![self saveRowOnDeselect]) return; + if (![[self onMainThread] saveRowOnDeselect]) return; // Update history [spHistoryControllerInstance updateHistoryEntries]; @@ -1095,7 +1096,7 @@ previousTableRowsCount = 0; [self clearTableValues]; [self loadTableValues]; - [tableContentView scrollPoint:NSMakePoint(0.0, 0.0)]; + [[tableContentView onMainThread] scrollPoint:NSMakePoint(0.0, 0.0)]; [tableDocumentInstance endTask]; [filterPool drain]; @@ -2840,7 +2841,7 @@ NSAutoreleasePool *sortPool = [[NSAutoreleasePool alloc] init]; // Check whether a save of the current row is required. - if (![self saveRowOnDeselect]) { + if (![[self onMainThread] saveRowOnDeselect]) { [sortPool drain]; return; } @@ -2850,11 +2851,19 @@ isDesc = !isDesc; } else { isDesc = NO; - [tableContentView setIndicatorImage:nil inTableColumn:[tableContentView tableColumnWithIdentifier:sortCol]]; + [[tableContentView onMainThread] setIndicatorImage:nil inTableColumn:[tableContentView tableColumnWithIdentifier:sortCol]]; } if (sortCol) [sortCol release]; sortCol = [[NSNumber alloc] initWithInteger:[[tableColumn identifier] integerValue]]; + // Set the highlight and indicatorImage + [[tableContentView onMainThread] setHighlightedTableColumn:tableColumn]; + if (isDesc) { + [[tableContentView onMainThread] setIndicatorImage:[NSImage imageNamed:@"NSDescendingSortIndicator"] inTableColumn:tableColumn]; + } else { + [[tableContentView onMainThread] setIndicatorImage:[NSImage imageNamed:@"NSAscendingSortIndicator"] inTableColumn:tableColumn]; + } + // Update data using the new sort order previousTableRowsCount = tableRowsCount; [self loadTableValues]; @@ -2867,14 +2876,6 @@ return; } - // Set the highlight and indicatorImage - [tableContentView setHighlightedTableColumn:tableColumn]; - if (isDesc) { - [tableContentView setIndicatorImage:[NSImage imageNamed:@"NSDescendingSortIndicator"] inTableColumn:tableColumn]; - } else { - [tableContentView setIndicatorImage:[NSImage imageNamed:@"NSAscendingSortIndicator"] inTableColumn:tableColumn]; - } - [tableDocumentInstance endTask]; [sortPool drain]; } -- cgit v1.2.3