Fix XIB loading bug reported by Julian Mayer as bug #34454.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33931 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2011-10-03 12:48:15 +00:00
parent db54238627
commit cab517b510
4 changed files with 56 additions and 3 deletions

View file

@ -1,3 +1,11 @@
2011-10-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSView.m (-initWithCoder:): Don't decode super view.
* Headers/Additions/GNUstepGUI/GSXibLoading.h: Add class IBBindingConnection.
* Source/GSXibLoader.m: Implement IBBindingConnection.
* Source/GSXibLoader.m (-objectForXib:): Return a previously
decoded object instead of a new one if available.
2011-10-01 Fred Kiefer <FredKiefer@gmx.de> 2011-10-01 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSMenuView.m (-_trackWithEvent:startingMenuView:, * Source/NSMenuView.m (-_trackWithEvent:startingMenuView:,

View file

@ -84,6 +84,12 @@
} }
@end @end
@interface IBBindingConnection: IBConnection
{
NSNibBindingConnector *connector;
}
@end
@interface IBConnectionRecord: NSObject @interface IBConnectionRecord: NSObject
{ {
IBConnection *connection; IBConnection *connection;

View file

@ -288,6 +288,35 @@
@end @end
@implementation IBBindingConnection
- (void) dealloc
{
DESTROY(connector);
[super dealloc];
}
- (id) initWithCoder: (NSCoder*)coder
{
self = [super initWithCoder: coder];
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"connector"])
{
ASSIGN(connector, [coder decodeObjectForKey: @"connector"]);
}
}
return self;
}
- (void) establishConnection
{
[connector establishConnection];
}
@end
@implementation IBConnectionRecord @implementation IBConnectionRecord
- (id) initWithCoder: (NSCoder*)coder - (id) initWithCoder: (NSCoder*)coder
@ -892,6 +921,16 @@ didStartElement: (NSString *)elementName
NSDebugLLog(@"XIB", @"decoding element %@", element); NSDebugLLog(@"XIB", @"decoding element %@", element);
key = [element attributeForKey: @"id"]; key = [element attributeForKey: @"id"];
if (key != nil)
{
id new = [decoded objectForKey: key];
if (new != nil)
{
// The object was already decoded as a reference
return new;
}
}
elementName = [element type]; elementName = [element type];
if ([@"object" isEqualToString: elementName]) if ([@"object" isEqualToString: elementName])
{ {

View file

@ -4697,8 +4697,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
NSInternalInconsistencyException); NSInternalInconsistencyException);
NSAssert([sub window] == nil, NSAssert([sub window] == nil,
NSInternalInconsistencyException); NSInternalInconsistencyException);
NSAssert([sub superview] == nil, NSAssert([sub superview] == nil,
NSInternalInconsistencyException); NSInternalInconsistencyException);
[sub _viewWillMoveToWindow: _window]; [sub _viewWillMoveToWindow: _window];
[sub _viewWillMoveToSuperview: self]; [sub _viewWillMoveToSuperview: self];
[sub setNextResponder: self]; [sub setNextResponder: self];
@ -4712,7 +4712,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
} }
// the superview... // the superview...
[aDecoder decodeObjectForKey: @"NSSuperview"]; //[aDecoder decodeObjectForKey: @"NSSuperview"];
} }
else else
{ {