From de22bc2880fb6b58617a2bc54d708723bddb4b29 Mon Sep 17 00:00:00 2001 From: gcasa Date: Tue, 2 Dec 2008 06:39:48 +0000 Subject: [PATCH] * Source/GSNibCompatibility.m: Fix for bug #24979. Change in initWithCoder: for NSCustomView to return the real object directly and call nibInstantiate. Change to prevent double instantiation of NSApplication. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27186 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Source/GSNibCompatibility.m | 23 ++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c0bdf68f..69bc612ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-12-02 01:21-EST Gregory John Casamento + + * Source/GSNibCompatibility.m: Fix for bug #24979. Change in + initWithCoder: for NSCustomView to return the real object directly + and call nibInstantiate. Change to prevent double instantiation + of NSApplication. + 2008-12-02 Gregory John Casamento * Source/NSSecureTextField.m: Added initWithCoder: method which diff --git a/Source/GSNibCompatibility.m b/Source/GSNibCompatibility.m index cfa486307..38dc97242 100644 --- a/Source/GSNibCompatibility.m +++ b/Source/GSNibCompatibility.m @@ -611,6 +611,7 @@ static BOOL _isInInterfaceBuilder = NO; { ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]); ASSIGN(_extension, [coder decodeObjectForKey: @"NSExtension"]); + ASSIGN(_object, [coder decodeObjectForKey: @"NSObject"]); } else { @@ -627,6 +628,7 @@ static BOOL _isInInterfaceBuilder = NO; { [coder encodeObject: (id)_className forKey: @"NSClassName"]; [coder encodeConditionalObject: (id)_extension forKey: @"NSExtension"]; + [coder encodeConditionalObject: (id)_object forKey: @"NSObject"]; } else { @@ -657,8 +659,15 @@ static BOOL _isInInterfaceBuilder = NO; [NSException raise: NSInternalInconsistencyException format: @"Unable to find class '%@'", _className]; } - - _object = [[aClass allocWithZone: NSDefaultMallocZone()] init]; + + if(GSObjCIsKindOf(aClass, [NSApplication class])) + { + _object = [aClass sharedApplication]; + } + else + { + _object = [[aClass allocWithZone: NSDefaultMallocZone()] init]; + } } return _object; } @@ -723,10 +732,10 @@ static BOOL _isInInterfaceBuilder = NO; { _view = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]]; [_view setAutoresizingMask: [self autoresizingMask]]; - [self setAutoresizesSubviews: [self autoresizesSubviews]]; - [self setHidden: [self isHidden]]; + [_view setAutoresizesSubviews: [self autoresizesSubviews]]; + [_view setHidden: [self isHidden]]; [_view setNextResponder: [self nextResponder]]; - [[self superview] replaceSubview: self with: _view]; // replace the old view... + // [[self superview] replaceSubview: self with: _view]; // replace the old view... if (_rFlags.has_subviews) { NSArray *subviews = [self subviews]; @@ -753,6 +762,10 @@ static BOOL _isInInterfaceBuilder = NO; { ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]); ASSIGN(_extension, [coder decodeObjectForKey: @"NSExtension"]); + + AUTORELEASE(self); + self = [self nibInstantiate]; + RETAIN(self); } else {