aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseDocument.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPDatabaseDocument.m')
-rw-r--r--Source/SPDatabaseDocument.m49
1 files changed, 27 insertions, 22 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index e122205e..1d4b4fc6 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];
}
}
@@ -871,30 +871,31 @@
*/
- (void)toggleConsole:(id)sender
{
- BOOL isConsoleVisible = [[[SPQueryController sharedQueryController] window] isVisible];
- // If the Console window is not visible data are not reloaded (for speed).
- // Due to that update list if user opens the Console window.
- if(!isConsoleVisible) {
- [[SPQueryController sharedQueryController] updateEntries];
- }
+ // Toggle Console will show the Console window if it isn't visible or if it isn't
+ // the front most window and hide it if it is the front most window
+ if ([[[SPQueryController sharedQueryController] window] isVisible]
+ && [[[NSApp keyWindow] windowController] isKindOfClass:[SPQueryController class]])
+
+ [[[SPQueryController sharedQueryController] window] setIsVisible:NO];
+ else
+
+ [self showConsole:nil];
- // Show or hide the console
- [[[SPQueryController sharedQueryController] window] setIsVisible:(!isConsoleVisible)];
}
/**
- * Brings the console to the fron
+ * Brings the console to the front
*/
- (void)showConsole:(id)sender
{
- BOOL isConsoleVisible = [[[SPQueryController sharedQueryController] window] isVisible];
- if (!isConsoleVisible) {
- [self toggleConsole:sender];
- } else {
- [[[SPQueryController sharedQueryController] window] makeKeyAndOrderFront:self];
- }
+ // If the Console window is not visible data are not reloaded (for speed).
+ // Due to that update list if user opens the Console window.
+ if(![[[SPQueryController sharedQueryController] window] isVisible])
+ [[SPQueryController sharedQueryController] updateEntries];
+
+ [[[SPQueryController sharedQueryController] window] makeKeyAndOrderFront:self];
}
@@ -3209,7 +3210,7 @@
// Show/hide console
if ([menuItem action] == @selector(toggleConsole:)) {
- [menuItem setTitle:([[[SPQueryController sharedQueryController] window] isVisible]) ? NSLocalizedString(@"Hide Console", @"hide console") : NSLocalizedString(@"Show Console", @"show console")];
+ [menuItem setTitle:([[[SPQueryController sharedQueryController] window] isVisible] && [[[NSApp keyWindow] windowController] isKindOfClass:[SPQueryController class]]) ? NSLocalizedString(@"Hide Console", @"hide console") : NSLocalizedString(@"Show Console", @"show console")];
}
// Clear console
@@ -3305,6 +3306,10 @@
*/
- (void) updateWindowTitle:(id)sender
{
+
+ // Ensure a call on the main thread
+ if (![NSThread isMainThread]) return [[self onMainThread] updateWindowTitle:sender];
+
NSMutableString *tabTitle;
NSMutableString *windowTitle;
SPDatabaseDocument *frontTableDocument = [parentWindowController selectedTableDocument];
@@ -4543,7 +4548,7 @@
- (void)connectionControllerConnectAttemptFailed:(id)controller
{
// Reset the window title
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
}
#pragma mark -
@@ -5506,7 +5511,7 @@
[tablesListInstance setConnection:mySQLConnection];
[tableDumpInstance setConnection:mySQLConnection];
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
}
/**
@@ -5545,7 +5550,7 @@
[tablesListInstance setConnection:mySQLConnection];
[tableDumpInstance setConnection:mySQLConnection];
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
}
/**
@@ -5602,7 +5607,7 @@
[tableDumpInstance setConnection:mySQLConnection];
// Update the window title
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
// Add a history entry
if (!historyStateChanging) {