* Source/NSAttributedString.m: Fix keyeded encodgin decoding for

both NSAttributedString and NSMutableAttributedString.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28453 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2009-08-11 17:01:50 +00:00
parent f1d2144948
commit 523ae77842
2 changed files with 63 additions and 34 deletions

View file

@ -1,3 +1,8 @@
2009-08-11 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSAttributedString.m: Fix keyeded encodgin decoding for
both NSAttributedString and NSMutableAttributedString.
2009-08-11 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSData.m: Fix memory leak introduced with GC changes.

View file

@ -152,6 +152,18 @@ static Class GSMutableAttributedStringClass;
- (void) encodeWithCoder: (NSCoder*)aCoder
{
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: [self string] forKey: @"NSString"];
if ([self length] > 0)
{
NSDictionary* attrs = [self attributesAtIndex: 0 effectiveRange: NULL];
[aCoder encodeObject: attrs forKey: @"NSAttributes"];
}
}
else
{
NSRange r = NSMakeRange(0, 0);
unsigned index = NSMaxRange(r);
unsigned length = [self length];
@ -166,6 +178,7 @@ static Class GSMutableAttributedStringClass;
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &index];
[aCoder encodeObject: attrs];
}
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
@ -627,6 +640,15 @@ static Class GSMutableAttributedStringClass;
- (id) initWithCoder: (NSCoder*)aDecoder
{
if ([aDecoder allowsKeyedCoding])
{
NSString *string = [aDecoder decodeObjectForKey: @"NSString"];
NSDictionary *attributes = [aDecoder decodeObjectForKey: @"NSAttributes"];
self = [self initWithString: string attributes: attributes];
}
else
{
NSString *string = [aDecoder decodeObject];
unsigned length = [string length];
@ -663,6 +685,8 @@ static Class GSMutableAttributedStringClass;
}
}
}
}
return self;
}