diff --git a/ChangeLog b/ChangeLog index d9efd8bf1..05d997a2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-02-16 Fred Kiefer + + * Source/NSCell.m (-setStringValue:, -setObjectValue:): Try to fix + bugs in last change. + 2009-02-15 22:21-EST Gregory John Casamento * Source/NSOpenPanel.m: Corrects bug #25471. Only enable diff --git a/Source/NSCell.m b/Source/NSCell.m index 0a512b379..8e645cedd 100644 --- a/Source/NSCell.m +++ b/Source/NSCell.m @@ -321,32 +321,33 @@ static NSColor *dtxtCol; _cell.contents_is_attributed_string = NO; _cell.has_valid_object_value = YES; } - if ([object isKindOfClass: [NSAttributedString class]] == YES) + else if ([object isKindOfClass: [NSAttributedString class]] == YES) { newContents = object; _cell.contents_is_attributed_string = YES; _cell.has_valid_object_value = YES; } + else if([_object_value respondsToSelector: @selector(attributedStringValue)]) + { + newContents = [_object_value attributedStringValue]; + _cell.contents_is_attributed_string = YES; + _cell.has_valid_object_value = YES; + } + else if([_object_value respondsToSelector: @selector(stringValue)]) + { + // If the thing that was assigned is not a string, but + // responds to stringValue then get that. + newContents = [_object_value stringValue]; + _cell.contents_is_attributed_string = NO; + _cell.has_valid_object_value = YES; + } else { - /// - // If the thing that was assigned is not a string, but - // responds to stringValue then get that. - /// - if([_object_value respondsToSelector: @selector(attributedStringValue)]) - { - newContents = [_object_value attributedStringValue]; - } - else if([_object_value respondsToSelector: @selector(stringValue)]) - { - newContents = [_object_value stringValue]; - } - - newContents = [_object_value description]; - _cell.contents_is_attributed_string = NO; - _cell.has_valid_object_value = YES; - } - } + newContents = [_object_value description]; + _cell.contents_is_attributed_string = NO; + _cell.has_valid_object_value = YES; + } + } else { newContents = [_formatter stringForObjectValue: _object_value]; @@ -415,11 +416,9 @@ static NSColor *dtxtCol; */ - (void) setStringValue: (NSString*)aString { - NSString *string = aString; - /* We warn about nil for compatibiliy with MacOS X, which refuses nil. */ - if (string == nil) + if (aString == nil) { NSDebugMLLog (@"MacOSXCompatibility", @"Attempt to use nil as string value"); @@ -429,44 +428,26 @@ static NSColor *dtxtCol; { [self setType: NSTextCellType]; } - _cell.contents_is_attributed_string = NO; if (_formatter == nil) { - if([string isKindOfClass: [NSString class]] == NO) - { - /// - // If the thing that was assigned is not a string, but - // responds to stringValue then get that. - /// - if([string respondsToSelector: @selector(attributedStringValue)]) - { - string = (NSString *)[(id)string attributedStringValue]; - } - else if([string respondsToSelector: @selector(stringValue)]) - { - string = (NSString *)[(id)string stringValue]; - } - } - - ASSIGN (_contents, string); - ASSIGN (_object_value, string); - _cell.has_valid_object_value = YES; + [self setObjectValue: aString]; } else { id newObjectValue; if ([_formatter getObjectValue: &newObjectValue - forString: string + forString: aString errorDescription: NULL]) { [self setObjectValue: newObjectValue]; } else { + ASSIGN (_contents, aString); + _cell.contents_is_attributed_string = NO; _cell.has_valid_object_value = NO; - ASSIGN (_contents, string); } } }