From 46cd34f22b35767d6f28f424a094ccef2e91c234 Mon Sep 17 00:00:00 2001 From: fedor Date: Tue, 27 Nov 2001 21:40:05 +0000 Subject: [PATCH] View coding fixes git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11553 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 9 +++++++++ Source/NSClipView.m | 20 ++++++++++++++------ Source/NSTabView.m | 4 ++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index f55d6d781..adaabb8c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-11-27 Adam Fedor + + * Source/NSClipView.m: Treat _documentView as a convienience + ivar. Don't release/retain or encode it. + (-initWithCoder:): Get _documentView from subview array. + * Source/NSTabView.m (-encodeWithCoder:): Conditionally encode + delegate. + (-initWithCoder:): Don't retain delegate. + 2001-11-26 Fred Kiefer * Headers/gnustep/gui/NSWindow.h diff --git a/Source/NSClipView.m b/Source/NSClipView.m index 69442848d..16753ce24 100644 --- a/Source/NSClipView.m +++ b/Source/NSClipView.m @@ -77,7 +77,11 @@ static inline NSRect integralRect (NSRect rect, NSView *view) } - +/* Note that the ivar _documentView is really just a convienience + variable. The actual document view is stored in NSClipView's + subview array. Deallocation, coding, etc of the view is then + handled by NSView +*/ @implementation NSClipView - (id) init @@ -102,7 +106,7 @@ static inline NSRect integralRect (NSRect rect, NSView *view) [nc removeObserver: _documentView name:nil object:self]; } - RELEASE(_documentView); + /* Don't RELEASE(_documentView), since it's already in our subviews. */ } RELEASE(_cursor); RELEASE(_backgroundColor); @@ -133,7 +137,8 @@ static inline NSRect integralRect (NSRect rect, NSView *view) [_documentView removeFromSuperview]; } - ASSIGN (_documentView, aView); + /* Don't retain this since it's stored in our subviews. */ + _documentView = aView; /* Call this before doing anything else ! */ _rFlags.flipped_view = [self isFlipped]; @@ -656,7 +661,6 @@ static inline NSRect integralRect (NSRect rect, NSView *view) [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_copiesOnScroll]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_drawsBackground]; [aCoder encodeObject: _cursor]; - [aCoder encodeObject: _documentView]; } - (id) initWithCoder: (NSCoder*)aDecoder @@ -671,8 +675,12 @@ static inline NSRect integralRect (NSRect rect, NSView *view) [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_drawsBackground]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_cursor]; - document = [aDecoder decodeObject]; - [self setDocumentView: document]; + if ([[self subviews] count] > 0) + { + document = AUTORELEASE(RETAIN([[self subviews] objectAtIndex: 0])); + [self removeSubview: document]; + [self setDocumentView: document]; + } return self; } diff --git a/Source/NSTabView.m b/Source/NSTabView.m index 688f1392b..7ab6dfb4e 100644 --- a/Source/NSTabView.m +++ b/Source/NSTabView.m @@ -703,7 +703,7 @@ [aCoder encodeValueOfObjCType: @encode(NSTabViewType) at: &_type]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_draws_background]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_truncated_label]; - [aCoder encodeObject: _delegate]; + [aCoder encodeConditionalObject: _delegate]; [aCoder encodeValueOfObjCType: "i" at: &_selected_item]; } @@ -716,7 +716,7 @@ [aDecoder decodeValueOfObjCType: @encode(NSTabViewType) at: &_type]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_draws_background]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_truncated_label]; - [aDecoder decodeValueOfObjCType: @encode(id) at: &_delegate]; + _delegate = [aDecoder decodeObject]; [aDecoder decodeValueOfObjCType: "i" at: &_selected_item]; return self;