From cab517b510f68ae10ea0b5324e91e7292aefac6d Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Mon, 3 Oct 2011 12:48:15 +0000 Subject: [PATCH] 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 --- ChangeLog | 8 +++++ Headers/Additions/GNUstepGUI/GSXibLoading.h | 6 ++++ Source/GSXibLoader.m | 39 +++++++++++++++++++++ Source/NSView.m | 6 ++-- 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95d790467..84107151f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-10-03 Fred Kiefer + + * 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 * Source/NSMenuView.m (-_trackWithEvent:startingMenuView:, diff --git a/Headers/Additions/GNUstepGUI/GSXibLoading.h b/Headers/Additions/GNUstepGUI/GSXibLoading.h index fb0fdb306..c3c023c24 100644 --- a/Headers/Additions/GNUstepGUI/GSXibLoading.h +++ b/Headers/Additions/GNUstepGUI/GSXibLoading.h @@ -84,6 +84,12 @@ } @end +@interface IBBindingConnection: IBConnection +{ + NSNibBindingConnector *connector; +} +@end + @interface IBConnectionRecord: NSObject { IBConnection *connection; diff --git a/Source/GSXibLoader.m b/Source/GSXibLoader.m index 5deb89f1e..022cfa91d 100644 --- a/Source/GSXibLoader.m +++ b/Source/GSXibLoader.m @@ -288,6 +288,35 @@ @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 - (id) initWithCoder: (NSCoder*)coder @@ -892,6 +921,16 @@ didStartElement: (NSString *)elementName NSDebugLLog(@"XIB", @"decoding element %@", element); 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]; if ([@"object" isEqualToString: elementName]) { diff --git a/Source/NSView.m b/Source/NSView.m index 67e017fdd..c6a595a84 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -4697,8 +4697,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level) NSInternalInconsistencyException); NSAssert([sub window] == nil, NSInternalInconsistencyException); - NSAssert([sub superview] == nil, - NSInternalInconsistencyException); + NSAssert([sub superview] == nil, + NSInternalInconsistencyException); [sub _viewWillMoveToWindow: _window]; [sub _viewWillMoveToSuperview: self]; [sub setNextResponder: self]; @@ -4712,7 +4712,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level) } // the superview... - [aDecoder decodeObjectForKey: @"NSSuperview"]; + //[aDecoder decodeObjectForKey: @"NSSuperview"]; } else {