diff options
author | rowanbeentje <rowan@beent.je> | 2010-01-24 21:02:18 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-01-24 21:02:18 +0000 |
commit | 9997d982ca4fcbacb04b41c7f7e2aa7dd44db312 (patch) | |
tree | 8672ff610b9b932d4f5c59a8223e2033ac95e3b5 /Source/TableDocument.m | |
parent | 127df973e23e7843320e470aad166ea587ab92eb (diff) | |
download | sequelpro-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/TableDocument.m')
-rw-r--r-- | Source/TableDocument.m | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/Source/TableDocument.m b/Source/TableDocument.m index d0410044..d8d16e85 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -2236,6 +2236,7 @@ - (void)closeConnection { [mySQLConnection disconnect]; + _isConnected = NO; // Disconnected Growl notification [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Disconnected" @@ -3425,7 +3426,7 @@ - (void)windowWillClose:(NSNotification *)aNotification { [mySQLConnection setDelegate:nil]; - if ([mySQLConnection isConnected]) [self closeConnection]; + if (_isConnected) [self closeConnection]; if ([[[SPQueryController sharedQueryController] window] isVisible]) [self toggleConsole:self]; [createTableSyntaxWindow orderOut:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self]; @@ -3436,22 +3437,26 @@ */ - (BOOL)windowShouldClose:(id)sender { - if (_isWorkingLevel) { - return NO; - } else if ( ![tablesListInstance selectionShouldChangeInTableView:nil] ) { - return NO; - } else { - if(!_isConnected) return YES; + // If no connection is available, always return YES. Covers initial setup and disconnections. + if(!_isConnected) return YES; - // Auto-save spf file based connection - if([self fileURL] && [[[self fileURL] absoluteString] length] && ![self isUntitled]) { - BOOL isSaved = [self saveDocumentWithFilePath:nil inBackground:YES onlyPreferences:YES]; - if(isSaved) - [[SPQueryController sharedQueryController] removeRegisteredDocumentWithFileURL:[self fileURL]]; - return isSaved; - } + // If tasks are active, return NO to allow tasks to complete + if (_isWorkingLevel) return NO; + + // If the table list considers itself to be working, return NO. This catches open alerts, and + // edits in progress in various views. + if ( ![tablesListInstance selectionShouldChangeInTableView:nil] ) return NO; + + // Auto-save spf file based connection and return whether the save was successful + if([self fileURL] && [[[self fileURL] absoluteString] length] && ![self isUntitled]) { + BOOL isSaved = [self saveDocumentWithFilePath:nil inBackground:YES onlyPreferences:YES]; + if(isSaved) + [[SPQueryController sharedQueryController] removeRegisteredDocumentWithFileURL:[self fileURL]]; + return isSaved; } + + // Return YES by default return YES; } |