From d638ce370f202cb9d8338eeb3f981d9f70f548ff Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 8 Mar 2010 00:20:24 +0000 Subject: - Move history popup construction to the main thread, fixing crashes probably caused by non-thread-safe menu interaction. This addresses http://log.sequelpro.com/view/19 --- Source/CustomQuery.m | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Source/CustomQuery.m') diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 2992d373..2e26f08e 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -713,8 +713,7 @@ // add query to history if(!reloadingExistingResult && [usedQuery length]) - [[SPQueryController sharedQueryController] addHistory:usedQuery forFileURL:[tableDocumentInstance fileURL]]; - + [self performSelectorOnMainThread:@selector(addHistoryEntry:) withObject:usedQuery waitUntilDone:NO]; // Error checking if ( [mySQLConnection queryCancelled] || ([errors length] && !queryIsTableSorter)) { @@ -2886,6 +2885,16 @@ { return [[[SPQueryController sharedQueryController] historyForFileURL:[tableDocumentInstance fileURL]] componentsJoinedByString:@";\n"]; } + +/** + * Add a query string to the file/global history, via the query controller. + * Single argument allows calls on the main thread. + */ +- (void)addHistoryEntry:(NSString *)entryString +{ + [[SPQueryController sharedQueryController] addHistory:entryString forFileURL:[tableDocumentInstance fileURL]]; +} + /* * This method is called as part of Key Value Observing which is used to watch for prefernce changes which effect the interface. */ -- cgit v1.2.3