Re: Removed view still getting events
Re: Removed view still getting events
- Subject: Re: Removed view still getting events
- From: John Nairn <email@hidden>
- Date: Fri, 29 Sep 2006 11:44:01 -0700
On Sep 29, 2006, at 11:09 AM, j o a r wrote:
On 28 sep 2006, at 23.56, John Nairn wrote:
Sorry, I am not sure where to get that. When it enters the
debugger, the thread-1 table lists
0 objc_msgSend_rtp
1 -[NSWindow sendEvent:]
2 -[NSApplication sendEvent:]
3 -[NSApplication run]
4 NSApplicationMain
5 _start
6 start
and signal was EXC_BAD_ACCESS
That's what I'm looking for. OK, I was hoping to see some of your
code in the backtrace, but no such luck.
Are you sure that the view is removed from the window / superview?
Can you log:
NSLog(@"view: %@, superview: %@", myView, [myView superview]);
...before and after removing it? Do you have anything else holding
references to the view? Is it properly deallocated right when it's
being removed from the superview, or at the end of the event loop,
or not at all? Add a log statement to it's dealloc method to find out.
Here are some NSLog()'s. It is removed from its superview and gets
deallocated, but it seems not until the end of the event loop.
NairnFEAMPM[15607] 3D windowDidLoad
NairnFEAMPM[15607] view: <TrackingGraphView: 0x6dfa20>, superview:
<NSClipView: 0x6df7a0>
NairnFEAMPM[15607] view: <TrackingGraphView: 0x6dfa20>, superview:
(null)
NairnFEAMPM[15607] 3D windowDidLoad ended
NairnFEAMPM[15607] openGL reshape
NairnFEAMPM[15607] drawRect
NairnFEAMPM[15607] dealloc TrackingGraphView
The first mouseEntered event after it is deallocated causes a crash
because that view was handling that event and it is now gone and for
some reason still getting the event.
From your description you do some view switching in -awakeFromNib,
and some in -windowDidLoad? Can you do all of it in -awakeFromNib?
All view elements use only awakeFromNib while windowDidLoad is in the
window controller class (which is the custom class of nib File's
owner). I did not think the file's owner would get awakeFromNib but
it does get windowDidLoad after all other elements have awakeFromNib.
You say that "[the scroll view] sets the graphics view to its
document view". That sounds a bit unusual. Usually, it would be the
window controller, or some other custom class, that did such a
thing. How is the scroll view locating the graphics view? Do you
have a custom scroll view subclass?
I have custom scroll class and add its document view as an outlet to
be linked up during awakeFromNib.
You also say "...just replace the scroll view and graphics view by
a new scoll view...". Do you really need to switch out the scroll
view? In most cases I would have expected it to suffice to switch
it's document view. Granted, if you have some special scroll view
subclass, I can see why that might be the case.
I do have custom scroll view and it handles various 2D graphics
tasks, mainly changing the scale to zoom in on the plot. Since
zooming will be done completely differently in 3D with OpenGL, I
wanted to use a new scroll view. Actually, for other reasons, I
decided to eliminate the scroll view for 3D and make an NSOpenGLView
subclass the contentView of the window. Thus I now want to swap out
the scroll view and its document view and replace it with an
NSOpenGLView. I have this new approach working but the problem with
the old view still getting events remains.
I got one ugly solution which is to have the window controller create
an entirely new window and then use setWindow method. It appears to
work except that the documentation says normally a window controller
class should not call this method?
Thanks for all your input.
---------------
John Nairn (1-541-737-4265, FAX:1-541-737-3385)
Professor and Richardson Chair
Web Page: http://woodscience.oregonstate.edu/faculty/Nairn
FEA/MPM Web Page: http://oregonstate.edu/~nairnj
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden