* Source/GSNibCompatibility.m: Correct bug #24780. There was an issue

in NSClassSwapper when decoding classes which use cells from nib files.
	* Source/NSSecureTextField.m: Encode in encodeWithCoder and 
	decodeWithCoder: a key for storing the bool _echosBullets.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27140 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2008-11-27 02:12:55 +00:00
parent c6e08b897c
commit 4c043a0017
3 changed files with 65 additions and 25 deletions

View file

@ -1,3 +1,10 @@
2008-11-26 21:09-EST Gregory John Casamento <greg_casamento@yahoo.com>
* Source/GSNibCompatibility.m: Correct bug #24780. There was an issue
in NSClassSwapper when decoding classes which use cells from nib files.
* Source/NSSecureTextField.m: Encode in encodeWithCoder and
decodeWithCoder: a key for storing the bool _echosBullets.
2008-11-26 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSTextView.m (-undoReplaceCharactersInRange:...,

View file

@ -863,6 +863,7 @@ static BOOL _isInInterfaceBuilder = NO;
@interface NSKeyedUnarchiver (NSClassSwapperPrivate)
- (BOOL) replaceObject: (id)oldObj withObject: (id)newObj;
- (NSDictionary *)keyMap;
- (Class) replacementClassForClassName: (NSString *)className;
@end
@implementation NSKeyedUnarchiver (NSClassSwapperPrivate)
@ -890,6 +891,21 @@ static BOOL _isInInterfaceBuilder = NO;
{
return _keyMap;
}
- (Class) replacementClassForClassName: (NSString *)className
{
Class aClass;
if ((aClass = [self classForClassName: className]) == nil)
{
aClass = NSClassFromString(className);
}
if (aClass == nil)
{
[NSException raise: NSInternalInconsistencyException
format: @"NSClassSwapper unable to find class '%@'", className];
}
return aClass;
}
@end
@implementation NSClassSwapper
@ -948,37 +964,48 @@ static BOOL _isInInterfaceBuilder = NO;
- (void) instantiateRealObject: (NSCoder *)coder withClassName: (NSString *)className
{
Class aClass = nil;
Class newClass = nil;
id object = nil;
NSKeyedUnarchiver *decoder = (NSKeyedUnarchiver *)coder;
// if there is a replacement class, use it, otherwise, use the one specified.
if ((aClass = [(NSKeyedUnarchiver *)coder classForClassName: className]) == nil)
{
aClass = NSClassFromString(className);
}
if (aClass == nil)
{
[NSException raise: NSInternalInconsistencyException
format: @"NSClassSwapper unable to find class '%@'", className];
}
newClass = [decoder replacementClassForClassName: className];
// swap the class...
object = [aClass allocWithZone: NSDefaultMallocZone()];
[(NSKeyedUnarchiver *)coder replaceObject: self withObject: object];
[self setTemplate: [object initWithCoder: coder]];
object = [newClass allocWithZone: NSDefaultMallocZone()];
[decoder setDelegate: self]; // set the delegate...
[decoder replaceObject: self withObject: object];
[self setTemplate: [object initWithCoder: decoder]];
if (object != _template)
{
[(NSKeyedUnarchiver *)coder replaceObject: object withObject: _template];
[decoder replaceObject: object withObject: _template];
}
[decoder setDelegate: nil]; // unset the delegate...
}
// Delegate method...
- (id) unarchiver: (NSKeyedUnarchiver *)coder
didDecodeObject: (id)obj
{
Class newClass = [coder replacementClassForClassName: _className];
id result = obj;
// if we are in an interface builder, then return the original object.
if ([NSClassSwapper isInInterfaceBuilder] == YES)
{
return obj;
}
if([aClass respondsToSelector: @selector(cellClass)] &&
[className isEqualToString: _originalClassName] == NO)
// if this is a class which uses cells, override with the new cellClass, if the
// subclass responds to cellClass.
if ([newClass respondsToSelector: @selector(cellClass)] &&
[_className isEqualToString: _originalClassName] == NO)
{
id oldCell = [_template cell];
id newCell = [[[aClass cellClass] alloc] init];
[_template setCell: newCell];
Class newCellClass = [newClass cellClass];
result = [[newCellClass alloc] initWithCoder: coder];
}
return result;
}
- (id) initWithCoder: (NSCoder *)coder

View file

@ -208,7 +208,7 @@
self = [super initWithCoder: decoder];
if ([decoder allowsKeyedCoding])
{
// do nothing for now...
_echosBullets = [decoder decodeBoolForKey: @"GSEchoBullets"];
}
else
{
@ -218,12 +218,18 @@
return self;
}
- (void) encodeWithCoder: (NSCoder *)aCoder
- (void) encodeWithCoder: (NSCoder *)coder
{
[super encodeWithCoder: aCoder];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_echosBullets];
[super encodeWithCoder: coder];
if([coder allowsKeyedCoding])
{
[coder encodeBool: _echosBullets forKey: @"GSEchoBullets"];
}
else
{
[coder encodeValueOfObjCType: @encode(BOOL) at: &_echosBullets];
}
}
@end
@implementation GSSimpleSecureLayoutManager