[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible bug with adding subviews?
From: |
Richard Frith-Macdonald |
Subject: |
Re: Possible bug with adding subviews? |
Date: |
Tue, 12 Feb 2002 19:33:54 +0000 |
On Tuesday, February 12, 2002, at 07:07 PM, Stephen Brandon wrote:
Hi,
I converted a MacOSX nib using nib2gmodel, and am debugging the
results :=(
The issue here is that GNUstep complains thus:
Uncaught exception NSInvalidArgumentException, reason: addSubview:
creates a
loop in the views tree!
The problem occurs under the following conditions:
- unarchiving from gmodel file
- NSBox object ("box") has contentview "a"
- nsview "a" also appears in box's subviews array
- nsview "a" has superview "box"
All the above look correct to me.
- during the unarchiving of "a" (superview "box" is decoded, then
[superview
addSubview:self] is called)
The exception is thrown in -[NSView addSubview:], where the box's
_content_view object is asked to add *itself*, since _content_view ==
"a":
if ([self isDescendantOf: aView]) {... (throws exception)
I'm not sure where the best place to fix this is. Should the unarchiver
do a
check to see if the superview's contentview equals itself? (but then the
superview would never add the view to its subview list). Or should
NSView
just do a check to see if a view is adding itself as a subview, and
silently
ignore it?
It's also possible that the situation as described above should never
actually happen, and that either my original nib is in a mess, or
nib2gmodel
made an error in converting it.
It sounds to me like there is an error in the decoder ... the NSView
decoder
is setting the subviews, then the NSBox specific code is setting the
content
view ... which adds it as a subview ... but it's already there.
There are three places it could be fixed ...
1. in the gmodel NSBox decoder
2. in the NSBox setContentView: method
3. in the NSView addSubview: method
I think 1 is almost certainly the correct place to change.
Re: Possible bug with adding subviews?,
Richard Frith-Macdonald <=