aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseStructure.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2013-10-27 21:26:58 +0000
committerstuconnolly <stuart02@gmail.com>2013-10-27 21:26:58 +0000
commite916ec2f6ad186c4dcb744f5e4bca521057a8e17 (patch)
treed453d02e24c5065c95d05b0cb54f6537903fa5ca /Source/SPDatabaseStructure.m
parentf7f27a1c2c37fe6cc433e0625ff75d609eb3e2c2 (diff)
downloadsequelpro-e916ec2f6ad186c4dcb744f5e4bca521057a8e17.tar.gz
sequelpro-e916ec2f6ad186c4dcb744f5e4bca521057a8e17.tar.bz2
sequelpro-e916ec2f6ad186c4dcb744f5e4bca521057a8e17.zip
Tidy up.
Diffstat (limited to 'Source/SPDatabaseStructure.m')
-rw-r--r--Source/SPDatabaseStructure.m57
1 files changed, 33 insertions, 24 deletions
diff --git a/Source/SPDatabaseStructure.m b/Source/SPDatabaseStructure.m
index 399fe3f7..7dc65910 100644
--- a/Source/SPDatabaseStructure.m
+++ b/Source/SPDatabaseStructure.m
@@ -85,7 +85,7 @@
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(destroy:)
name:SPDocumentWillCloseNotification
- object:theDelegate];
+ object:delegate];
// Set up the connection, thread management and data locks
pthread_mutex_init(&threadManagementLock, NULL);
@@ -103,9 +103,11 @@
*/
- (void)setConnectionToClone:(SPMySQLConnection *)aConnection
{
-
// Perform the task in a background thread to avoid blocking the UI
- [NSThread detachNewThreadWithName:@"SPDatabaseStructure clone connection task" target:self selector:@selector(_cloneConnectionFromConnection:) object:aConnection];
+ [NSThread detachNewThreadWithName:@"SPDatabaseStructure clone connection task"
+ target:self
+ selector:@selector(_cloneConnectionFromConnection:)
+ object:aConnection];
}
/**
@@ -117,38 +119,25 @@
// Ensure all the retrieval threads have ended
pthread_mutex_lock(&threadManagementLock);
+
if ([structureRetrievalThreads count]) {
- for (NSThread *eachThread in structureRetrievalThreads) {
+ for (NSThread *eachThread in structureRetrievalThreads)
+ {
[eachThread cancel];
}
- while ([structureRetrievalThreads count]) {
+
+ while ([structureRetrievalThreads count])
+ {
pthread_mutex_unlock(&threadManagementLock);
usleep(100000);
pthread_mutex_lock(&threadManagementLock);
}
}
+
pthread_mutex_unlock(&threadManagementLock);
}
-- (void)dealloc
-{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
-
- [self destroy:nil];
- [structureRetrievalThreads release];
-
- pthread_mutex_destroy(&threadManagementLock);
- pthread_mutex_destroy(&dataLock);
- pthread_mutex_destroy(&connectionCheckLock);
-
- if (mySQLConnection) [mySQLConnection release], mySQLConnection = nil;
- if (structure) [structure release], structure = nil;
- if (allKeysofDbStructure) [allKeysofDbStructure release], allKeysofDbStructure = nil;
-
- [super dealloc];
-}
-
#pragma mark -
#pragma mark Information
@@ -165,7 +154,7 @@
* executed on the helper connection.
* Should always be executed on a background thread.
*/
-- (void)queryDbStructureWithUserInfo:(NSDictionary*)userInfo
+- (void)queryDbStructureWithUserInfo:(NSDictionary *)userInfo
{
NSAutoreleasePool *queryPool = [[NSAutoreleasePool alloc] init];
BOOL structureWasUpdated = NO;
@@ -573,6 +562,26 @@
return [delegate keychainPasswordForConnection:connection];
}
+#pragma mark -
+
+- (void)dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+ [self destroy:nil];
+ [structureRetrievalThreads release];
+
+ pthread_mutex_destroy(&threadManagementLock);
+ pthread_mutex_destroy(&dataLock);
+ pthread_mutex_destroy(&connectionCheckLock);
+
+ if (mySQLConnection) [mySQLConnection release], mySQLConnection = nil;
+ if (structure) [structure release], structure = nil;
+ if (allKeysofDbStructure) [allKeysofDbStructure release], allKeysofDbStructure = nil;
+
+ [super dealloc];
+}
+
@end
#pragma mark -