From a5adeec3a56b0d1c47ded03187840d92f63b2976 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 31 Jan 2011 23:39:19 +0000 Subject: - Ensure window title updates occur on the main thread, fixing crashes under race conditions --- Source/SPDatabaseDocument.m | 16 ++++++++++------ Source/SPDatabaseViewController.m | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'Source') diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 96bfbf39..adff490d 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -835,12 +835,12 @@ if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; selectedDatabase = [[NSString alloc] initWithString:dbName]; [chooseDatabaseButton selectItemWithTitle:selectedDatabase]; - [[self onMainThread] updateWindowTitle:self]; + [self updateWindowTitle:self]; } } else { if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; [chooseDatabaseButton selectItemAtIndex:0]; - [[self onMainThread] updateWindowTitle:self]; + [self updateWindowTitle:self]; } } @@ -3305,6 +3305,10 @@ */ - (void) updateWindowTitle:(id)sender { + + // Ensure a call on the main thread + if (![NSThread isMainThread]) return [self updateWindowTitle:sender]; + NSMutableString *tabTitle; NSMutableString *windowTitle; SPDatabaseDocument *frontTableDocument = [parentWindowController selectedTableDocument]; @@ -4543,7 +4547,7 @@ - (void)connectionControllerConnectAttemptFailed:(id)controller { // Reset the window title - [[self onMainThread] updateWindowTitle:self]; + [self updateWindowTitle:self]; } #pragma mark - @@ -5506,7 +5510,7 @@ [tablesListInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; - [[self onMainThread] updateWindowTitle:self]; + [self updateWindowTitle:self]; } /** @@ -5545,7 +5549,7 @@ [tablesListInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; - [[self onMainThread] updateWindowTitle:self]; + [self updateWindowTitle:self]; } /** @@ -5602,7 +5606,7 @@ [tableDumpInstance setConnection:mySQLConnection]; // Update the window title - [[self onMainThread] updateWindowTitle:self]; + [self updateWindowTitle:self]; // Add a history entry if (!historyStateChanging) { diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m index e95b6b41..a7867c53 100644 --- a/Source/SPDatabaseViewController.m +++ b/Source/SPDatabaseViewController.m @@ -287,7 +287,7 @@ triggersLoaded = NO; // Update the window title - [[self onMainThread] updateWindowTitle:self]; + [self updateWindowTitle:self]; // Add a history entry [spHistoryControllerInstance updateHistoryEntries]; @@ -391,7 +391,7 @@ NSString *tableEncoding = nil; // Update the window title - [[self onMainThread] updateWindowTitle:self]; + [self updateWindowTitle:self]; // Reset table information caches [tableDataInstance resetAllData]; -- cgit v1.2.3