aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-29 18:17:17 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-29 18:17:17 +0000
commitd4d1243d665aee61cde560468d72bb0ecfee3bd8 (patch)
treebefb5ea17009dbbd5781303dad2c68cc6a8ee51e
parentd8f38f5740abe258fbcf339c6a666415e67feb57 (diff)
downloadsequelpro-d4d1243d665aee61cde560468d72bb0ecfee3bd8.tar.gz
sequelpro-d4d1243d665aee61cde560468d72bb0ecfee3bd8.tar.bz2
sequelpro-d4d1243d665aee61cde560468d72bb0ecfee3bd8.zip
• fixed several threading issues due to threading
- collection classes as NSMutableSet are NOT thread safe! • further tiny speed improvements for navigator
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h2
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m16
-rw-r--r--Source/SPNavigatorController.m19
3 files changed, 19 insertions, 18 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
index bf5d4145..05078a60 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
@@ -159,7 +159,7 @@
NSString *serverVersionString;
NSMutableDictionary *structure;
- NSMutableSet *allKeysofDbStructure;
+ NSMutableArray *allKeysofDbStructure;
NSTimer *keepAliveTimer;
double lastKeepAliveTime;
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index c4d41778..26f1a9b4 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -116,7 +116,7 @@ static BOOL sTruncateLongFieldInLogs = YES;
keepAliveInterval = 60;
structure = [[NSMutableDictionary alloc] initWithCapacity:1];
- allKeysofDbStructure = [[NSMutableSet alloc] initWithCapacity:20];
+ allKeysofDbStructure = [[NSMutableArray alloc] initWithCapacity:20];
isQueryingDbStructure = NO;
connectionThreadId = 0;
@@ -1880,12 +1880,13 @@ void performThreadedKeepAlive(void *ptr)
NSDictionary *dbstructure = [[[self delegate] getDbStructure] retain];
[structure removeAllObjects];
[structure setObject:[NSMutableDictionary dictionaryWithDictionary:dbstructure] forKey:connectionID];
- NSArray *allStructureKeys = [[[self delegate] allSchemaKeys] retain];
+ NSArray *allStructureKeys = [[self delegate] allSchemaKeys];
if(allStructureKeys && [allStructureKeys count]) {
- [allKeysofDbStructure removeAllObjects];
- [allKeysofDbStructure addObjectsFromArray:allStructureKeys];
+ if(allKeysofDbStructure) [allKeysofDbStructure release];
+ allKeysofDbStructure = nil;
+ allKeysofDbStructure = [[NSMutableArray alloc] initWithCapacity:[allKeysofDbStructure count]];
+ [allKeysofDbStructure setArray:allStructureKeys];
}
- if(allStructureKeys) [allStructureKeys release], allStructureKeys = nil;
if(dbstructure) [dbstructure release], dbstructure = nil;
BOOL removeAddFlag = NO;
@@ -2215,8 +2216,9 @@ void performThreadedKeepAlive(void *ptr)
*/
- (NSArray *)getAllKeysOfDbStructure
{
- if(allKeysofDbStructure && [allKeysofDbStructure count])
- return [allKeysofDbStructure allObjects];
+ if(allKeysofDbStructure && [allKeysofDbStructure count]) {
+ return [NSArray arrayWithArray:allKeysofDbStructure];
+ }
return [NSArray array];
}
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m
index 30418e1e..abf709b8 100644
--- a/Source/SPNavigatorController.m
+++ b/Source/SPNavigatorController.m
@@ -394,6 +394,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
if([object isKindOfClass:[TableDocument class]])
[updatingConnections addObject:[object connectionID]];
+
}
- (void)updateEntriesForConnection:(NSString*)connectionID
@@ -440,7 +441,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
[[schemaData objectForKey:connectionName] setObject:[[structureData objectForKey:connectionName] objectForKey:item] forKey:item];
if([theConnection getAllKeysOfDbStructure])
- [allSchemaKeys setObject:[theConnection getAllKeysOfDbStructure] forKey:connectionName];
+ [allSchemaKeys setObject:[[NSSet setWithArray:[theConnection getAllKeysOfDbStructure]] allObjects] forKey:connectionName];
} else {
[schemaData setObject:[NSDictionary dictionary] forKey:[NSString stringWithFormat:@"%@&DEL&no data loaded yet", connectionName]];
[allSchemaKeys setObject:[NSArray array] forKey:connectionName];
@@ -798,10 +799,9 @@ static SPNavigatorController *sharedNavigatorController = nil;
if(!parentObject) return @"…";
if ([[tableColumn identifier] isEqualToString:@"field"]) {
-
// top level is connection
+ [[tableColumn dataCell] setImage:[NSImage imageNamed:@"network-small"]];
if([outlineView levelForItem:item] == 0) {
- [[tableColumn dataCell] setImage:[NSImage imageNamed:@"network-small"]];
if([parentObject allKeysForObject:item] && [[parentObject allKeysForObject:item] count]) {
NSString *key = [[parentObject allKeysForObject:item] objectAtIndex:0];
if([key rangeOfString:@"&SSH&"].length)
@@ -882,7 +882,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
}
}
- if ([item isKindOfClass:[NSArray class]] && [item count]>5 && [[parentObject allKeysForObject:item] count] && ![[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "])
+ if([outlineView levelForItem:item] == 3 && [item isKindOfClass:[NSArray class]])
{
NSString *typ = [NSString stringWithFormat:@"%@,%@,%@", [[item objectAtIndex:0] stringByReplacingOccurrencesOfRegex:@"\\(.*?,.*?\\)" withString:@"(…)"], [item objectAtIndex:3], [item objectAtIndex:5]];
NSTokenFieldCell *b = [[[NSTokenFieldCell alloc] initTextCell:typ] autorelease];
@@ -901,10 +901,10 @@ static SPNavigatorController *sharedNavigatorController = nil;
- (BOOL)outlineView:outlineView isGroupItem:(id)item
{
- if ([item isKindOfClass:[NSDictionary class]] || [outlineView levelForItem:item] == 1)
- return YES;
+ if ([outlineView levelForItem:item] == 3)
+ return NO;
- return NO;
+ return YES;
}
- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
@@ -918,8 +918,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
if(!parentObject) return 0;
- // Use " struct_type " as placeholder to increase distance between table and first field name otherwise it looks ugly
- if([parentObject allKeysForObject:item] && [[parentObject allKeysForObject:item] count] && [[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "])
+ if([outlineView levelForItem:item] == 3 && [outlineView isExpandable:[outlineView itemAtRow:[outlineView rowForItem:item]-1]])
return 5.0;
return 18.0;
@@ -941,7 +940,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
if(!parentObject) return NO;
- if([parentObject allKeysForObject:item] && [[parentObject allKeysForObject:item] count] && [[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "])
+ if([outlineView levelForItem:item] == 3 && [outlineView isExpandable:[outlineView itemAtRow:[outlineView rowForItem:item]-1]])
return NO;
return YES;
}