From: <ama...@us...> - 2006-08-03 16:56:50
|
Revision: 7218 Author: amaxwell Date: 2006-08-03 09:56:48 -0700 (Thu, 03 Aug 2006) ViewCVS: http://svn.sourceforge.net/bibdesk/?rev=7218&view=rev Log Message: ----------- use accessors to avoid some code duplication remove no-op statement; if necessary to assign to @"", please comment, since setting this to empty/nil will result in a parser error Modified Paths: -------------- trunk/bibdesk/BibItem.m Modified: trunk/bibdesk/BibItem.m =================================================================== --- trunk/bibdesk/BibItem.m 2006-08-03 16:52:49 UTC (rev 7217) +++ trunk/bibdesk/BibItem.m 2006-08-03 16:56:48 UTC (rev 7218) @@ -407,13 +407,12 @@ #define ADD_KEY(s) if([pubFields objectForKey: s usingReadWriteLock:bibLock] == nil){[pubFields setObject:@"" forKey: s usingReadWriteLock:bibLock];} [removeKeys removeObject: s]; - (void)makeType{ - [bibLock lockForReading]; NSString *fieldString; + NSString *theType = [self pubType]; BibTypeManager *typeMan = [BibTypeManager sharedManager]; - NSEnumerator *reqFieldsE = [[typeMan requiredFieldsForType:pubType] objectEnumerator]; - NSEnumerator *optFieldsE = [[typeMan optionalFieldsForType:pubType] objectEnumerator]; - NSEnumerator *defFieldsE = [[typeMan userDefaultFieldsForType:pubType] objectEnumerator]; - [bibLock unlockForReading]; + NSEnumerator *reqFieldsE = [[typeMan requiredFieldsForType:theType] objectEnumerator]; + NSEnumerator *optFieldsE = [[typeMan optionalFieldsForType:theType] objectEnumerator]; + NSEnumerator *defFieldsE = [[typeMan userDefaultFieldsForType:theType] objectEnumerator]; NSMutableArray *removeKeys = [NSMutableArray array]; NSEnumerator *keyE = [[self allFieldNames] objectEnumerator]; @@ -868,9 +867,7 @@ } - (void)setPubType:(NSString *)newType withModDate:(NSCalendarDate *)date{ - [bibLock lockForReading]; - NSString *oldType = [[pubType copy] autorelease]; - [bibLock unlockForReading]; + NSString *oldType = [self pubType]; if ([oldType isEqualToString:newType]) { return; @@ -925,9 +922,8 @@ } - (void)setCiteKey:(NSString *)newCiteKey withModDate:(NSCalendarDate *)date{ - [bibLock lockForReading]; - NSString *oldCiteKey = [citeKey retain]; - [bibLock unlockForReading]; + NSString *oldCiteKey = [self citeKey]; + if ([self undoManager]) { [[[self undoManager] prepareWithInvocationTarget:self] setCiteKey:oldCiteKey withModDate:[self dateModified]]; @@ -954,7 +950,8 @@ } - (void)setCiteKeyString:(NSString *)newCiteKey{ - if (newCiteKey == nil) newCiteKey == @""; + // parser doesn't allow empty cite keys + OBPRECONDITION([NSString isEmptyString:newCiteKey] == NO); [bibLock lockForWriting]; [citeKey autorelease]; citeKey = [newCiteKey copy]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |