From 9997d982ca4fcbacb04b41c7f7e2aa7dd44db312 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sun, 24 Jan 2010 21:02:18 +0000 Subject: 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. --- Source/SPConnectionDelegate.m | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'Source/SPConnectionDelegate.m') 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 -- cgit v1.2.3