diff options
author | rowanbeentje <rowan@beent.je> | 2012-03-18 00:51:52 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-03-18 00:51:52 +0000 |
commit | f6de38fa5cc34461513670e52d5a9801ff8d8b32 (patch) | |
tree | 03112f12ba5dafcbcf0c61fc944737fcb82a3a08 /Source/SPDatabaseStructure.m | |
parent | 7d10648fdbe4378b3b478572184c6b81d67b454d (diff) | |
download | sequelpro-f6de38fa5cc34461513670e52d5a9801ff8d8b32.tar.gz sequelpro-f6de38fa5cc34461513670e52d5a9801ff8d8b32.tar.bz2 sequelpro-f6de38fa5cc34461513670e52d5a9801ff8d8b32.zip |
- Fix crashes caused by the database structure retrieval continuing briefly after the parent document was closed
Diffstat (limited to 'Source/SPDatabaseStructure.m')
-rw-r--r-- | Source/SPDatabaseStructure.m | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Source/SPDatabaseStructure.m b/Source/SPDatabaseStructure.m index 42896b55..3579e269 100644 --- a/Source/SPDatabaseStructure.m +++ b/Source/SPDatabaseStructure.m @@ -95,8 +95,12 @@ [NSThread detachNewThreadSelector:@selector(_cloneConnectionFromConnection:) toTarget:self withObject:aConnection]; } -- (void)dealloc +/** + * Ensure that processing is completed. + */ +- (void)destroy { + delegate = nil; // Ensure all the retrieval threads have ended pthread_mutex_lock(&threadManagementLock); @@ -111,12 +115,17 @@ } } pthread_mutex_unlock(&threadManagementLock); + +} + +- (void)dealloc +{ + [self destroy]; [structureRetrievalThreads release]; pthread_mutex_destroy(&threadManagementLock); pthread_mutex_destroy(&dataLock); pthread_mutex_destroy(&connectionCheckLock); - delegate = nil; if (mySQLConnection) [mySQLConnection release], mySQLConnection = nil; if (structure) [structure release], structure = nil; @@ -619,7 +628,7 @@ - (BOOL)_ensureConnection { - if (!mySQLConnection) return NO; + if (!mySQLConnection || !delegate) return NO; // Check the connection state if ([mySQLConnection isConnected] && [mySQLConnection checkConnection]) return YES; |