From d8f38f5740abe258fbcf339c6a666415e67feb57 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 29 Mar 2010 14:22:37 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20some=20more=20sanity=20checks=20to?= =?UTF-8?q?=20avoid=20exceptions=20due=20to=20threading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPNavigatorController.m | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'Source') 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; } /** -- cgit v1.2.3