Revision: 18113
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18113&view=rev
Author: hofman
Date: 2011-09-07 12:46:45 +0000 (Wed, 07 Sep 2011)
Log Message:
-----------
make sure error is mutable before setting a value
Modified Paths:
--------------
trunk/bibdesk/BibDocument.m
trunk/bibdesk/BibItem.m
trunk/bibdesk/NSError_BDSKExtensions.h
trunk/bibdesk/NSError_BDSKExtensions.m
Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2011-09-07 12:32:27 UTC (rev 18112)
+++ trunk/bibdesk/BibDocument.m 2011-09-07 12:46:45 UTC (rev 18113)
@@ -1484,8 +1484,10 @@
}
isOK = [outputData appendDataFromString:templateFile encoding:encoding
error:&error];
- if(NO == isOK)
+ if(NO == isOK){
+ if ([error isMutable] == NO) error = [[error mutableCopy]
autorelease];
[error setValue:NSLocalizedString(@"Unable to convert template
string.", @"string encoding error context")
forKey:NSLocalizedRecoverySuggestionErrorKey];
+ }
} else if ([NSString isEmptyString:frontMatter]) {
shouldAppendFrontMatter = NO;
}
@@ -1496,16 +1498,20 @@
if(isOK && shouldAppendFrontMatter){
hasData = YES;
isOK = [outputData appendDataFromString:frontMatter encoding:encoding
error:&error];
- if(NO == isOK)
+ if(NO == isOK){
+ if ([error isMutable] == NO) error = [[error mutableCopy]
autorelease];
[error setValue:NSLocalizedString(@"Unable to convert file
header.", @"string encoding error context")
forKey:NSLocalizedRecoverySuggestionErrorKey];
+ }
[outputData appendData:doubleNewlineData];
}
if(isOK && [documentInfo count]){
hasData = YES;
isOK = [outputData appendDataFromString:[self documentInfoString]
encoding:encoding error:&error];
- if(NO == isOK)
+ if(NO == isOK){
+ if ([error isMutable] == NO) error = [[error mutableCopy]
autorelease];
[error setValue:NSLocalizedString(@"Unable to convert document
info.", @"string encoding error context")
forKey:NSLocalizedRecoverySuggestionErrorKey];
+ }
}
// output the document's macros:
@@ -1514,8 +1520,10 @@
if ([NSString isEmptyString:macroString] == NO) {
hasData = YES;
isOK = [outputData appendDataFromString:macroString
encoding:encoding error:&error];
- if(NO == isOK)
+ if(NO == isOK){
+ if ([error isMutable] == NO) error = [[error mutableCopy]
autorelease];
[error setValue:NSLocalizedString(@"Unable to convert
macros.", @"string encoding error context")
forKey:NSLocalizedRecoverySuggestionErrorKey];
+ }
}
}
@@ -1530,8 +1538,10 @@
if((isOK = (pubData != nil))){
[outputData appendData:doubleNewlineData];
[outputData appendData:pubData];
- }else if([error valueForKey:NSLocalizedRecoverySuggestionErrorKey]
== nil)
+ }else if([error valueForKey:NSLocalizedRecoverySuggestionErrorKey]
== nil){
+ if ([error isMutable] == NO) error = [[error mutableCopy]
autorelease];
[error setValue:[NSString
stringWithFormat:NSLocalizedString(@"Unable to convert item with cite key %@.",
@"string encoding error context"), [pub citeKey]]
forKey:NSLocalizedRecoverySuggestionErrorKey];
+ }
}
}
@@ -1542,31 +1552,40 @@
isOK = [outputData appendDataFromString:@"\n\n@comment{BibDesk
Static Groups{\n" encoding:encoding error:&error] &&
[outputData appendStringData:[groups
serializedGroupsDataOfType:BDSKStaticGroupType]
convertedFromUTF8ToEncoding:groupsEncoding error:&error] &&
[outputData appendDataFromString:@"}}" encoding:encoding
error:&error];
- if(NO == isOK)
+ if(NO == isOK){
+ if ([error isMutable] == NO) error = [[error mutableCopy]
autorelease];
[error setValue:NSLocalizedString(@"Unable to convert static
groups.", @"string encoding error context")
forKey:NSLocalizedRecoverySuggestionErrorKey];
+ }
}
if(isOK && ([[groups smartGroups] count] > 0)){
hasData = YES;
isOK = [outputData appendDataFromString:@"\n\n@comment{BibDesk
Smart Groups{\n" encoding:encoding error:&error] &&
[outputData appendStringData:[groups
serializedGroupsDataOfType:BDSKSmartGroupType]
convertedFromUTF8ToEncoding:groupsEncoding error:&error] &&
[outputData appendDataFromString:@"}}" encoding:encoding
error:&error];
+ if(NO == isOK){
+ if ([error isMutable] == NO) error = [[error mutableCopy]
autorelease];
[error setValue:NSLocalizedString(@"Unable to convert smart
groups.", @"string encoding error context")
forKey:NSLocalizedRecoverySuggestionErrorKey];
+ }
}
if(isOK && ([[groups URLGroups] count] > 0)){
hasData = YES;
isOK = [outputData appendDataFromString:@"\n\n@comment{BibDesk URL
Groups{\n" encoding:encoding error:&error] &&
[outputData appendStringData:[groups
serializedGroupsDataOfType:BDSKURLGroupType]
convertedFromUTF8ToEncoding:groupsEncoding error:&error] &&
[outputData appendDataFromString:@"}}" encoding:encoding
error:&error];
- if(NO == isOK)
+ if(NO == isOK){
+ if ([error isMutable] == NO) error = [[error mutableCopy]
autorelease];
[error setValue:NSLocalizedString(@"Unable to convert external
file groups.", @"string encoding error context")
forKey:NSLocalizedRecoverySuggestionErrorKey];
+ }
}
if(isOK && ([[groups scriptGroups] count] > 0)){
hasData = YES;
isOK = [outputData appendDataFromString:@"\n\n@comment{BibDesk
Script Groups{\n" encoding:encoding error:&error] &&
[outputData appendStringData:[groups
serializedGroupsDataOfType:BDSKScriptGroupType]
convertedFromUTF8ToEncoding:groupsEncoding error:&error] &&
[outputData appendDataFromString:@"}}" encoding:encoding
error:&error];
- if(NO == isOK)
+ if(NO == isOK){
+ if ([error isMutable] == NO) error = [[error mutableCopy]
autorelease];
[error setValue:NSLocalizedString(@"Unable to convert script
groups.", @"string encoding error context")
forKey:NSLocalizedRecoverySuggestionErrorKey];
+ }
}
}
Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m 2011-09-07 12:32:27 UTC (rev 18112)
+++ trunk/bibdesk/BibItem.m 2011-09-07 12:46:45 UTC (rev 18113)
@@ -1720,7 +1720,7 @@
isOK = [data appendDataFromString:typeAndCiteKey encoding:encoding
error:&error];
if(isOK == NO) {
- error = [[error mutableCopy] autorelease];
+ if ([error isMutable] == NO) error = [[error mutableCopy] autorelease];
[error setValue:[NSString stringWithFormat:NSLocalizedString(@"Unable
to convert cite key of item with cite key \"%@\".", @"string encoding error
context"), [self citeKey]] forKey:NSLocalizedRecoverySuggestionErrorKey];
}
Modified: trunk/bibdesk/NSError_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSError_BDSKExtensions.h 2011-09-07 12:32:27 UTC (rev
18112)
+++ trunk/bibdesk/NSError_BDSKExtensions.h 2011-09-07 12:46:45 UTC (rev
18113)
@@ -83,6 +83,7 @@
// see if it has our local domain
- (BOOL)isLocalError;
+- (BOOL)isMutable;
// embed an underlying error; if this isn't a mutable subclass, raises an
exception
- (void)embedError:(NSError *)underlyingError;
Modified: trunk/bibdesk/NSError_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSError_BDSKExtensions.m 2011-09-07 12:32:27 UTC (rev
18112)
+++ trunk/bibdesk/NSError_BDSKExtensions.m 2011-09-07 12:46:45 UTC (rev
18113)
@@ -113,6 +113,11 @@
return [[self valueForKey:@"__BDSKErrorCode"] integerValue];
}
+- (BOOL)isMutable;
+{
+ return YES;
+}
+
@end
@implementation NSError (BDSKExtensions)
@@ -173,4 +178,9 @@
return [[self userInfo] valueForKey:aKey];
}
+- (BOOL)isMutable;
+{
+ return NO;
+}
+
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit