Skip to content

Commit

Permalink
Merge pull request #387 from steipete/master
Browse files Browse the repository at this point in the history
Fixes exception crash if enum is defined more than once.
  • Loading branch information
robvdveer committed Jan 6, 2014
2 parents 8aafacd + 7e6d773 commit 63e6e97
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Model/GBStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ -(void)registerTypedefEnum:(GBTypedefEnumData *)typedefEnum
if ([_typedefEnums containsObject:typedefEnum]) return;
GBProtocolData *existingTypedef = [_typedefEnumsByName objectForKey:typedefEnum.nameOfEnum];
if (existingTypedef) {
[NSException raise:@"Typedef with name %@ is already registered!", typedefEnum.nameOfEnum];
return;
}
GBLogWarn(@"Ignoring typedef enum %@, already defined.", typedefEnum);
return;
}

[_typedefEnums addObject:typedefEnum];
[_typedefEnumsByName setObject:typedefEnum forKey:typedefEnum.nameOfEnum];
}
Expand All @@ -130,10 +131,11 @@ - (void)registerDocument:(GBDocumentData *)document {
if ([_documents containsObject:document]) return;
NSString *name = [document.nameOfDocument stringByDeletingPathExtension];
GBDocumentData *existingDocument = [_documentsByName objectForKey:name];
if (existingDocument) {
[NSException raise:@"Document with name %@ is already registered!", name];
return;
}
if (existingDocument) {
GBLogWarn(@"Ignoring document %@, already defined.", document);
return;
}

[_documents addObject:document];
[_documentsByName setObject:document forKey:name];
[_documentsByName setObject:document forKey:[name stringByReplacingOccurrencesOfString:@"-template" withString:@""]];
Expand Down

0 comments on commit 63e6e97

Please sign in to comment.