aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionDelegate.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-01-24 21:02:18 +0000
committerrowanbeentje <rowan@beent.je>2010-01-24 21:02:18 +0000
commit9997d982ca4fcbacb04b41c7f7e2aa7dd44db312 (patch)
tree8672ff610b9b932d4f5c59a8223e2033ac95e3b5 /Source/SPConnectionDelegate.m
parent127df973e23e7843320e470aad166ea587ab92eb (diff)
downloadsequelpro-9997d982ca4fcbacb04b41c7f7e2aa7dd44db312.tar.gz
sequelpro-9997d982ca4fcbacb04b41c7f7e2aa7dd44db312.tar.bz2
sequelpro-9997d982ca4fcbacb04b41c7f7e2aa7dd44db312.zip
Improve Disconnection on connection loss:
- Set error strings on MCPConnection on user disconnect to allow existing error chcking to catch the state - Improve close behaviour from threads - Improve window close behaviour and appearance - Add new checks for disconnection in one or two crash-prone locations This addresses Issue #531, one of Issue #532, one of Issue #539, and probable reported crashes on Issue #541.
Diffstat (limited to 'Source/SPConnectionDelegate.m')
-rw-r--r--Source/SPConnectionDelegate.m18
1 files changed, 16 insertions, 2 deletions
diff --git a/Source/SPConnectionDelegate.m b/Source/SPConnectionDelegate.m
index 2742c7a8..ff0cca23 100644
--- a/Source/SPConnectionDelegate.m
+++ b/Source/SPConnectionDelegate.m
@@ -118,11 +118,25 @@
// If 'disconnect' was selected, trigger a window close.
if (connectionErrorCode == MCPConnectionCheckDisconnect) {
- [self windowWillClose:nil];
- [tableWindow performSelector:@selector(close) withObject:nil afterDelay:0.0];
+ [self performSelectorOnMainThread:@selector(closeConnection) withObject:nil waitUntilDone:YES];
}
return connectionErrorCode;
}
+/**
+ * Close the connection - should be performed on the main thread.
+ * First hides the window to give code a little bit of time to clean
+ * everything up before it's all deallocated as a result of the close.
+ * Also sets alpha to fully transparent so accidental dialogs are hidden!
+ */
+- (void) closeConnection
+{
+ _isConnected = NO;
+ [self windowWillClose:nil];
+ [tableWindow orderOut:self];
+ [tableWindow setAlphaValue:0.0];
+ [tableWindow performSelector:@selector(close) withObject:nil afterDelay:1.0];
+}
+
@end