aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionHandler.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-10-14 16:09:45 +0000
committerrowanbeentje <rowan@beent.je>2012-10-14 16:09:45 +0000
commitdc45c654aab99cbccecda192396dc8baefd5690e (patch)
treea1b0a16eb468e191177c3617fc1f3c73c3e4750f /Source/SPConnectionHandler.m
parent7d14dae0476ee3e3ab7c2fac391c506ac320d5ea (diff)
downloadsequelpro-dc45c654aab99cbccecda192396dc8baefd5690e.tar.gz
sequelpro-dc45c654aab99cbccecda192396dc8baefd5690e.tar.bz2
sequelpro-dc45c654aab99cbccecda192396dc8baefd5690e.zip
- In the SPMySQL.framework, separate framework-triggered connections and disconnections from external actions, and use that separation to perform safer disconnects
- When closing a database document, add a new notification, and use that to resolve retain cycles affecting connection processes - Improve connection controller disconnection when the document is closed, fixing crashes, by building on those two features (addresses Issue #1396) - Use some of the new functionality to improve SSH and MySQL connection cancellation, making both cancelable in the interface and making both respond much more quickly
Diffstat (limited to 'Source/SPConnectionHandler.m')
-rw-r--r--Source/SPConnectionHandler.m45
1 files changed, 13 insertions, 32 deletions
diff --git a/Source/SPConnectionHandler.m b/Source/SPConnectionHandler.m
index 1a85bc50..3495eb95 100644
--- a/Source/SPConnectionHandler.m
+++ b/Source/SPConnectionHandler.m
@@ -69,9 +69,9 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
[progressIndicatorText setStringValue:NSLocalizedString(@"Connecting...", @"Generic connecting very short status message")];
}
[progressIndicatorText display];
-
+
[connectButton setTitle:NSLocalizedString(@"Cancel", @"cancel button")];
- [connectButton setAction:@selector(cancelMySQLConnection:)];
+ [connectButton setAction:@selector(cancelConnection:)];
[connectButton setEnabled:YES];
[connectButton display];
#endif
@@ -250,6 +250,11 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
}
[progressIndicatorText display];
+ [connectButton setTitle:NSLocalizedString(@"Cancel", @"cancel button")];
+ [connectButton setAction:@selector(cancelConnection:)];
+ [connectButton setEnabled:YES];
+ [connectButton display];
+
// Trim whitespace and newlines from the SSH host field before attempting to connect
[self setSshHost:[[self sshHost] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
@@ -285,18 +290,10 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
{
isConnecting = NO;
- // If the user hit cancel during the connection attempt, or a test connection is
- // occurring, kill the connection once established and reset the UI.
- if (mySQLConnectionCancelled || isTestingConnection) {
- if ([mySQLConnection isConnected]) {
- [mySQLConnection disconnect];
- [mySQLConnection release], mySQLConnection = nil;
- }
-
- // Kill the SSH connection if present
- [self cancelConnection];
-
- [self _restoreConnectionInterface];
+ // If the user is only testing the connection, kill the connection
+ // once established and reset the UI.
+ if (isTestingConnection) {
+ [self cancelConnection:self];
if (isTestingConnection) {
[self _showConnectionTestResult:NSLocalizedString(@"Connection succeeded", @"Connection success very short status message")];
@@ -387,21 +384,6 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
}
}
-/*
- * Cancel connection.
- */
-- (void)cancelConnection
-{
- cancellingConnection = YES;
-
- if (!sshTunnel) return;
-
- [sshTunnel disconnect];
- [sshTunnel release];
-
- sshTunnel = nil;
-}
-
/**
* Add the connection to the parent document and restore the
* interface, allowing the application to run as normal.
@@ -463,9 +445,8 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
[[(NSObject *)delegate onMainThread] connectionControllerConnectAttemptFailed:self];
}
- // Only display the connection error message if there is a window visible and the connection attempt
- // wasn't cancelled even though it failed.
- if ([[dbDocument parentWindow] isVisible] && (!mySQLConnectionCancelled)) {
+ // Only display the connection error message if there is a window visible
+ if ([[dbDocument parentWindow] 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, [dbDocument parentWindow], self, @selector(connectionFailureSheetDidEnd:returnCode:contextInfo:), @"connect", theErrorMessage);
}
}