diff options
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 12 | ||||
-rw-r--r-- | Source/SPNavigatorController.m | 29 |
2 files changed, 28 insertions, 13 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 683cda7d..c4d41778 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -1877,10 +1877,16 @@ void performThreadedKeepAlive(void *ptr) connectionID = @"_"; // Re-init with already cached data from navigator controller + NSDictionary *dbstructure = [[[self delegate] getDbStructure] retain]; [structure removeAllObjects]; - [structure setObject:[NSMutableDictionary dictionaryWithDictionary:[[self delegate] getDbStructure]] forKey:connectionID]; - [allKeysofDbStructure removeAllObjects]; - [allKeysofDbStructure addObjectsFromArray:[[self delegate] allSchemaKeys]]; + [structure setObject:[NSMutableDictionary dictionaryWithDictionary:dbstructure] forKey:connectionID]; + NSArray *allStructureKeys = [[[self delegate] allSchemaKeys] retain]; + if(allStructureKeys && [allStructureKeys count]) { + [allKeysofDbStructure removeAllObjects]; + [allKeysofDbStructure addObjectsFromArray:allStructureKeys]; + } + if(allStructureKeys) [allStructureKeys release], allStructureKeys = nil; + if(dbstructure) [dbstructure release], dbstructure = nil; BOOL removeAddFlag = NO; diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m index 90a6fdf2..30418e1e 100644 --- a/Source/SPNavigatorController.m +++ b/Source/SPNavigatorController.m @@ -181,7 +181,7 @@ static SPNavigatorController *sharedNavigatorController = nil; selection = [outlineSchema1 selectedItem]; if(selection) { id parentObject = [outlineSchema1 parentForItem:selection] ? [outlineSchema1 parentForItem:selection] : schemaData; - if(!parentObject) return; + if(!parentObject || ![parentObject isKindOfClass:[NSDictionary class]] || ![parentObject objectForKey:selection]) return; id parentKeys = [parentObject allKeysForObject:selection]; if(parentKeys && [parentKeys count] == 1) selectedKey1 = [[parentKeys objectAtIndex:0] description]; @@ -195,7 +195,7 @@ static SPNavigatorController *sharedNavigatorController = nil; selection = [outlineSchema2 selectedItem]; if(selection) { id parentObject = [outlineSchema2 parentForItem:selection] ? [outlineSchema2 parentForItem:selection] : schemaData; - if(!parentObject) return; + if(!parentObject || ![parentObject isKindOfClass:[NSDictionary class]] || ![parentObject objectForKey:selection]) return; id parentKeys = [parentObject allKeysForObject:selection]; if(parentKeys && [parentKeys count] == 1) selectedKey2 = [[parentKeys objectAtIndex:0] description]; @@ -321,11 +321,17 @@ static SPNavigatorController *sharedNavigatorController = nil; } if(docCounter > 1) return; - - [schemaDataFiltered removeObjectForKey:connectionID]; - [schemaData removeObjectForKey:connectionID]; - [allSchemaKeys removeObjectForKey:connectionID]; - [self saveSelectedItems]; + + if(schemaData && [schemaData objectForKey:connectionID]) + [self saveSelectedItems]; + + if(schemaDataFiltered) + [schemaDataFiltered removeObjectForKey:connectionID]; + if(schemaData) + [schemaData removeObjectForKey:connectionID]; + if(allSchemaKeys) + [allSchemaKeys removeObjectForKey:connectionID]; + [outlineSchema1 reloadData]; [outlineSchema2 reloadData]; [self restoreSelectedItems]; @@ -481,9 +487,12 @@ static SPNavigatorController *sharedNavigatorController = nil; - (NSArray *)allSchemaKeysForConnection:(NSString*)connectionID { - if([allSchemaKeys objectForKey:connectionID]) - return [NSArray arrayWithArray:[allSchemaKeys objectForKey:connectionID]]; - return [NSArray array]; + if([allSchemaKeys objectForKey:connectionID]) { + NSArray *a = [allSchemaKeys objectForKey:connectionID]; + if(a && [a count]) + return a; + } + return nil; } /** |