From a401c044675a24d9ee0508b6014cc691349485e9 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 26 Aug 2013 00:26:58 +0000 Subject: - Improve thread safety within the console window, triggering draw and view updates only on the main window - Ensure the console window is first loaded on the main thread, fixing warnings from CoreAnimation ("CoreAnimation: warning, deleted thread with uncommitted CATransaction") on startup when a background thread calls [window isVisible] and triggers a lazy awakeFromNib of the window --- Source/SPQueryController.m | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'Source') diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index f4586cf3..929de617 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -116,6 +116,10 @@ static SPQueryController *sharedQueryController = nil; NSError *error = [self loadCompletionLists]; + // Trigger a load of the nib to prevent problems if it's lazy-loaded on first console message + // on a bckground thread + [[[self onMainThread] window] displayIfNeeded]; + if (error) { NSLog(@"Error loading completion tokens data: %@", [error localizedDescription]); } @@ -595,17 +599,15 @@ static SPQueryController *sharedQueryController = nil; && [self _messageMatchesCurrentFilters:[consoleMessage message]]) { [messagesFilteredSet addObject:[messagesFullSet lastObject]]; - [saveConsoleButton setEnabled:YES]; - [clearConsoleButton setEnabled:YES]; + [[saveConsoleButton onMainThread] setEnabled:YES]; + [[clearConsoleButton onMainThread] setEnabled:YES]; } // Reload the table and scroll to the new message if it's visible (for speed) if (allowConsoleUpdate && [[self window] isVisible]) { - [consoleTableView noteNumberOfRowsChanged]; - [consoleTableView scrollRowToVisible:([messagesVisibleSet count] - 1)]; - [consoleTableView reloadData]; + [[self onMainThread] updateEntries]; } - + pthread_mutex_unlock(&consoleLock); #endif } -- cgit v1.2.3