[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSWindow mishandles fieldEditor when dealloc:ing
From: |
Nicola Pero |
Subject: |
Re: NSWindow mishandles fieldEditor when dealloc:ing |
Date: |
Mon, 4 Mar 2002 09:52:05 +0000 (GMT) |
> Hi,
>
> If an NSWindow is dealloc:ed with an active field editor the field
> editor isn't removed from the window (although it is released).
Thanks - I see why the crash but ... I think this is rather a bug in
NSView -dealloc.
NSView -dealloc should not only release the subview array; because that
does not necessarily dealloc all of the subviews, it should remove all the
subviews from the superview first ! At least, it should clear out the
pointer to self in the subviews (which it has itself set up), since that
will be invalid after he deallocated himself.
I think it is basically an ingenuity of NSView -dealloc which is assuming
that releasing the subviews will deallocate them ... which is not
necessarily true. The case of the window shared text field editor is just
a special case of this more general behaviour - a subview which is
released but not deallocated when the superview is deallocated. The
superview should make sure the subview is left in a consistent usable
state (and not containing pointers to deallocated objects!).
Any comments ?
> (This
> causes a crash if the field editor had a blinking cursor; when the timer
> fires it will try to tell the now-dealloc:ed superview to redraw
> itself.)
I see what you mean but I didn't have time to build a testcase - if you
have a testcase it would be appreciated. :-)