diff options
author | rowanbeentje <rowan@beent.je> | 2011-01-31 23:39:19 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2011-01-31 23:39:19 +0000 |
commit | a5adeec3a56b0d1c47ded03187840d92f63b2976 (patch) | |
tree | e6a5a8bd231c6bc331a220496a6deb0190f65560 | |
parent | 01f5d5e8bae1d39096c418678e82f59c021c195d (diff) | |
download | sequelpro-a5adeec3a56b0d1c47ded03187840d92f63b2976.tar.gz sequelpro-a5adeec3a56b0d1c47ded03187840d92f63b2976.tar.bz2 sequelpro-a5adeec3a56b0d1c47ded03187840d92f63b2976.zip |
- Ensure window title updates occur on the main thread, fixing crashes under race conditions
-rw-r--r-- | Source/SPDatabaseDocument.m | 16 | ||||
-rw-r--r-- | Source/SPDatabaseViewController.m | 4 |
2 files changed, 12 insertions, 8 deletions
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]; |