Re: Listener related crashing bug releasing subviews of a custom view
Re: Listener related crashing bug releasing subviews of a custom view
- Subject: Re: Listener related crashing bug releasing subviews of a custom view
- From: Ken Tozier <email@hidden>
- Date: Fri, 22 Feb 2008 11:22:57 -0500
Thanks for the tips Martin. (I particularly like [self
observationInfo]. Very helpful)
I tried both your suggestions and wrote a loop in the dealloc method
to force "[model removeObserver: self forKeyPath: @"pageNumber"];" on
all subviews but still no luck.
Here's the call stack
#0 0x90a59380 in objc_msgSend
#1 0xa327b5c4 in _NSAppKitGlobalLock
#2 0x005375ed in -[PMPageNumberField dealloc] at PMPageNumberField.m:72
#3 0x9329ea87 in -[NSView release]
#4 0x927e28af in NSPopAutoreleasePool
#5 0x928452e6 in __NSFireTimer
#6 0x9082d76a in CFRunLoopRunSpecific
#7 0x9082ca56 in CFRunLoopRunInMode
#8 0x92dec878 in RunCurrentEventLoopInMode
#9 0x92debf82 in ReceiveNextEventCommon
#10 0x92debdd9 in BlockUntilNextEventMatchingListInMode
#11 0x93292485 in _DPSNextEvent
#12 0x93292076 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#13 0x9328bdfb in -[NSApplication run]
#14 0x9327fd4f in NSApplicationMain
#15 0x00011ffc in main at main.m:13
And here's the method and line where the crash seems to happen
- (void) dealloc
{
NSLog(@"Entered: PMPageNumberField:dealloc");
[self removeModelObserver];
[super dealloc];
}
I rewrote the dealloc method to perform the remove observer step
directly and got the following call stack on crash
- (void) dealloc
{
NSLog(@"Entered: PMPageNumberField:dealloc");
[model removeObserver: self forKeyPath: @"pageNumber"];
[super dealloc];
}
#0 0x90a59380 in objc_msgSend
#1 0xa327b5c4 in _NSAppKitGlobalLock
#2 0x9329ea87 in -[NSView release]
#3 0x927e28af in NSPopAutoreleasePool
#4 0x928452e6 in __NSFireTimer
#5 0x9082d76a in CFRunLoopRunSpecific
#6 0x9082ca56 in CFRunLoopRunInMode
#7 0x92dec878 in RunCurrentEventLoopInMode
#8 0x92debf82 in ReceiveNextEventCommon
#9 0x92debdd9 in BlockUntilNextEventMatchingListInMode
#10 0x93292485 in _DPSNextEvent
#11 0x93292076 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#12 0x9328bdfb in -[NSApplication run]
#13 0x9327fd4f in NSApplicationMain
#14 0x00011ffc in main at main.m:13
From this, it appears that it crashes the instant dealloc is called.
Do the above call stacks shed any light on the problem?
Ken
On Feb 22, 2008, at 10:37 AM, Martin wrote:
How do I follow the error message suggestion and "Break on
_NSKVODeallocateLog to start debugging"?
It means that you should add a breakpoint that breaks on "
_NSKVODeallocateLog". To do so, open the breakpoints window, double
click on "double-click for symbol" and type "_NSKVODeallocateLog"
in the symbol text field.
Then you can see from the call stack where dealloc function is called.
I don't know if this can help, but at anytime, you can NSLog or
print in the debugger ("po [self observationInfo]") your object's
observationInfo which contains the list of all the observers.
-Martin
PS: I think that kind of message should be posted in cocoa-dev
rather that xcode-users.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden