aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m21
-rw-r--r--Source/SPConnectionController.m6
-rw-r--r--Source/SPConnectionDelegate.m27
3 files changed, 34 insertions, 20 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index a94584ee..4b5ac737 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -388,16 +388,23 @@ static BOOL sTruncateLongFieldInLogs = YES;
connectionThreadId = mConnection->thread_id;
[self timeZone]; // Getting the timezone used by the server.
- isMaxAllowedPacketEditable = [self isMaxAllowedPacketEditable];
-
- if (![self fetchMaxAllowedPacket]) {
- [self setLastErrorMessage:nil];
+ // Only attempt to set the max allowed packet if we have a connection
+ if (mConnection != NULL) {
- lastQueryErrorId = mysql_errno(mConnection);
+ isMaxAllowedPacketEditable = [self isMaxAllowedPacketEditable];
- return mConnected = NO;
+ if (![self fetchMaxAllowedPacket]) {
+ [self setLastErrorMessage:nil];
+
+ lastQueryErrorId = mysql_errno(mConnection);
+
+ mConnected = NO;
+ }
+ }
+ else {
+ mConnected = NO;
+ isMaxAllowedPacketEditable = NO;
}
-
return mConnected;
}
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 9d646278..f2d5fcdd 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -436,8 +436,10 @@
[delegate connectionControllerConnectAttemptFailed:self];
}
- // Display the connection error message
- SPBeginAlertSheet(theTitle, NSLocalizedString(@"OK", @"OK button"), (errorDetail) ? NSLocalizedString(@"Show Detail", @"Show detail button") : nil, (isSSHTunnelBindError) ? NSLocalizedString(@"Use Standard Connection", @"use standard connection button") : nil, documentWindow, self, nil, @selector(errorSheetDidEnd:returnCode:contextInfo:), @"connect", theErrorMessage);
+ // Only display the connection error message if there is a window visible
+ if ([documentWindow isVisible]) {
+ SPBeginAlertSheet(theTitle, NSLocalizedString(@"OK", @"OK button"), (errorDetail) ? NSLocalizedString(@"Show Detail", @"Show detail button") : nil, (isSSHTunnelBindError) ? NSLocalizedString(@"Use Standard Connection", @"use standard connection button") : nil, documentWindow, self, nil, @selector(errorSheetDidEnd:returnCode:contextInfo:), @"connect", theErrorMessage);
+ }
}
/**
diff --git a/Source/SPConnectionDelegate.m b/Source/SPConnectionDelegate.m
index 56a254fa..ae67697c 100644
--- a/Source/SPConnectionDelegate.m
+++ b/Source/SPConnectionDelegate.m
@@ -110,17 +110,22 @@
*/
- (MCPConnectionCheck)connectionLost:(id)connection
{
-
- // Display the connection error dialog and wait for the return code
- [NSApp beginSheet:connectionErrorDialog modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil];
- NSInteger connectionErrorCode = [NSApp runModalForWindow:connectionErrorDialog];
-
- [NSApp endSheet:connectionErrorDialog];
- [connectionErrorDialog orderOut:nil];
-
- // If 'disconnect' was selected, trigger a window close.
- if (connectionErrorCode == MCPConnectionCheckDisconnect) {
- [self performSelectorOnMainThread:@selector(closeDocumentWindowAndDisconnect) withObject:nil waitUntilDone:YES];
+ NSInteger connectionErrorCode = MCPConnectionCheckDisconnect;
+
+ // Only display the reconnect dialog if the window is visible
+ if ([tableWindow isVisible]) {
+
+ // Display the connection error dialog and wait for the return code
+ [NSApp beginSheet:connectionErrorDialog modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil];
+ connectionErrorCode = [NSApp runModalForWindow:connectionErrorDialog];
+
+ [NSApp endSheet:connectionErrorDialog];
+ [connectionErrorDialog orderOut:nil];
+
+ // If 'disconnect' was selected, trigger a window close.
+ if (connectionErrorCode == MCPConnectionCheckDisconnect) {
+ [self performSelectorOnMainThread:@selector(closeDocumentWindowAndDisconnect) withObject:nil waitUntilDone:YES];
+ }
}
return connectionErrorCode;