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 | |
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')
-rw-r--r-- | Source/SPDatabaseDocument.m | 1 | ||||
-rw-r--r-- | Source/SPDatabaseStructure.h | 3 | ||||
-rw-r--r-- | Source/SPDatabaseStructure.m | 15 |
3 files changed, 15 insertions, 4 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index cff43d9b..7fd93c1b 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -5647,6 +5647,7 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; #endif + [databaseStructureRetrieval destroy]; [databaseStructureRetrieval release]; [allDatabases release]; diff --git a/Source/SPDatabaseStructure.h b/Source/SPDatabaseStructure.h index 2b2d6977..52e43ec8 100644 --- a/Source/SPDatabaseStructure.h +++ b/Source/SPDatabaseStructure.h @@ -39,9 +39,10 @@ pthread_mutex_t connectionCheckLock; } -// Setup +// Setup and teardown - (id)initWithDelegate:(SPDatabaseDocument *)theDelegate; - (void)setConnectionToClone:(SPMySQLConnection *)aConnection; +- (void)destroy; // Information - (SPMySQLConnection *)connection; 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; |