From c42b7483546e0cdfa1dd82cdda1d18313e6af111 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Wed, 6 Oct 2010 15:40:05 +0000 Subject: When the user cancels a conenction attempt, which subsequently results in an error, don't bother displaying the error sheet. Also, disable the 'cancel' connection button once pressed. --- Source/SPConnectionController.m | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index baa09262..44b35d8d 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -306,6 +306,8 @@ */ - (IBAction)cancelMySQLConnection:(id)sender { + [connectButton setEnabled:NO]; + [progressIndicatorText setStringValue:NSLocalizedString(@"Cancelling...", @"cancelling task status message")]; [progressIndicatorText display]; @@ -354,11 +356,14 @@ * Currently only cleans up the SSH connection (MySQL connection isn't threaded) */ - (void)cancelConnection -{ +{ if (!sshTunnel) return; + cancellingConnection = YES; + [sshTunnel disconnect]; [sshTunnel release]; + sshTunnel = nil; } @@ -442,8 +447,9 @@ [delegate connectionControllerConnectAttemptFailed:self]; } - // Only display the connection error message if there is a window visible - if ([[tableDocument parentWindow] isVisible]) { + // Only display the connection error message if there is a window visible and the connection attempt + // wasn't cancelled even though it failed. + if ([[tableDocument parentWindow] isVisible] && (!mySQLConnectionCancelled)) { SPBeginAlertSheet(theTitle, NSLocalizedString(@"OK", @"OK button"), (errorDetail) ? NSLocalizedString(@"Show Detail", @"Show detail button") : nil, (isSSHTunnelBindError) ? NSLocalizedString(@"Use Standard Connection", @"use standard connection button") : nil, [tableDocument parentWindow], self, @selector(connectionFailureSheetDidEnd:returnCode:contextInfo:), @"connect", theErrorMessage); } } @@ -453,7 +459,6 @@ */ - (void)connectionFailureSheetDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { - // Restore the passwords from keychain for editing if appropriate if (connectionKeychainItemName) { [self setPassword:[keychain getPasswordForName:connectionKeychainItemName account:connectionKeychainItemAccount]]; @@ -1322,6 +1327,9 @@ // Must be performed on the main thread if (![NSThread isMainThread]) return [[self onMainThread] _restoreConnectionInterface]; + // Reset the window title + [[tableDocument parentWindow] setTitle:[tableDocument displayName]]; + // Stop the current tab's progress indicator [tableDocument setIsProcessing:NO]; -- cgit v1.2.3