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 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Source/SPDatabaseDocument.m') 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) { -- cgit v1.2.3