* Source/NSTextStorage.m (-classForCoder, -initWithCoder:,

-encodeWithCoder:): Encode this class and not the concrete 
  one. Also call super encoding/decoding methods as they are
  correct in base now.
* Source/GSTextStorage.m (-classForPortCoder, -encodeWithCoder:,
  -replacementObjectForPortCoder:): Remove these methods.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28456 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2009-08-12 22:00:16 +00:00
parent 5ea075f5ab
commit 81cf28902a
3 changed files with 24 additions and 31 deletions

View file

@ -1,3 +1,12 @@
2009-08-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTextStorage.m (-classForCoder, -initWithCoder:,
-encodeWithCoder:): Encode this class and not the concrete
one. Also call super encoding/decoding methods as they are
correct in base now.
* Source/GSTextStorage.m (-classForPortCoder, -encodeWithCoder:,
-replacementObjectForPortCoder:): Remove these methods.
2009-08-10 23:25-EDT Gregory John Casamento <greg.casamento@gmail.com> 2009-08-10 23:25-EDT Gregory John Casamento <greg.casamento@gmail.com>
* Sounds/Basso.wav * Sounds/Basso.wav

View file

@ -464,28 +464,9 @@ _attributesAtIndexEffectiveRange(
} }
} }
- (Class) classForPortCoder
{
return [self class];
}
- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder
{
return self;
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding] == NO)
{
[aCoder encodeValueOfObjCType: @encode(id) at: &_textChars];
[aCoder encodeValueOfObjCType: @encode(id) at: &_infoArray];
}
}
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
NSLog(@"Warning - decoding archive containing obsolete %@ object - please delete/replace this archive", NSStringFromClass([self class]));
self = [super initWithCoder: aCoder]; self = [super initWithCoder: aCoder];
if([aCoder allowsKeyedCoding] == NO) if([aCoder allowsKeyedCoding] == NO)
{ {
@ -498,20 +479,20 @@ _attributesAtIndexEffectiveRange(
- (id) initWithString: (NSString*)aString - (id) initWithString: (NSString*)aString
attributes: (NSDictionary*)attributes attributes: (NSDictionary*)attributes
{ {
NSZone *z = [self zone]; NSZone *z = [self zone];
self = [super initWithString: aString attributes: attributes]; self = [super initWithString: aString attributes: attributes];
_infoArray = [[NSMutableArray allocWithZone: z] initWithCapacity: 1]; _infoArray = [[NSMutableArray allocWithZone: z] initWithCapacity: 1];
if (aString != nil && [aString isKindOfClass: [NSAttributedString class]]) if (aString != nil && [aString isKindOfClass: [NSAttributedString class]])
{ {
NSAttributedString *as = (NSAttributedString*)aString; NSAttributedString *as = (NSAttributedString*)aString;
aString = [as string]; aString = [as string];
_setAttributesFrom(as, NSMakeRange(0, [aString length]), _infoArray); _setAttributesFrom(as, NSMakeRange(0, [aString length]), _infoArray);
} }
else else
{ {
GSTextInfo *info; GSTextInfo *info;
if (attributes == nil) if (attributes == nil)
{ {
@ -541,7 +522,7 @@ _attributesAtIndexEffectiveRange(
- (NSDictionary*) attributesAtIndex: (unsigned)index - (NSDictionary*) attributesAtIndex: (unsigned)index
effectiveRange: (NSRange*)aRange effectiveRange: (NSRange*)aRange
{ {
unsigned dummy; unsigned dummy;
return _attributesAtIndexEffectiveRange( return _attributesAtIndexEffectiveRange(
index, aRange, [_textChars length], _infoArray, &dummy); index, aRange, [_textChars length], _infoArray, &dummy);

View file

@ -337,33 +337,36 @@ static NSNotificationCenter *nc = nil;
[self fixAttributesInRange: range]; [self fixAttributesInRange: range];
} }
- (Class) classForCoder
{
return abstract;
}
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
self = [super initWithCoder: aDecoder];
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
id delegate = [aDecoder decodeObjectForKey: @"NSDelegate"]; id delegate = [aDecoder decodeObjectForKey: @"NSDelegate"];
NSString *string = [aDecoder decodeObjectForKey: @"NSString"];
self = [self initWithString: string];
[self setDelegate: delegate]; [self setDelegate: delegate];
} }
else else
{ {
self = [super initWithCoder: aDecoder]; }
}
return self; return self;
} }
- (void) encodeWithCoder: (NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder
{ {
[super encodeWithCoder: coder];
if ([coder allowsKeyedCoding]) if ([coder allowsKeyedCoding])
{ {
[coder encodeObject: [self delegate] forKey: @"NSDelegate"]; [coder encodeObject: [self delegate] forKey: @"NSDelegate"];
[coder encodeObject: [self string] forKey: @"NSString"];
} }
else else
{ {
[super encodeWithCoder: coder];
} }
} }