RE: Application crashes after launching Open/Save dialogs
RE: Application crashes after launching Open/Save dialogs
- Subject: RE: Application crashes after launching Open/Save dialogs
- From: Sanyam Jain <email@hidden>
- Date: Fri, 12 Aug 2011 11:05:29 +0530
- Acceptlanguage: en-US
- Thread-topic: Application crashes after launching Open/Save dialogs
Thanks a lot for the reply.
I was able to figure out the problem.
I was doing following sequence of things -
- NSOpenPanel* openPanelRef = [[NSOpenPanel alloc] init]; // created an instance of open panel
- MyCustomDelegate* openPanelDelegate = [[MyCustomDelegate alloc] init]; // created instance of custom delegate
- [openPanelRef setDelegate : openPanelDelegate]; // attached as a delegate
- [openPanelRef runModal]; // ran the modal open dialog
- // Missed something here
- [openPanelRef release];
- [openPanelDelegate release];
- After all the open stuff, whenever I open any other window, application used to crash.
The fix was placing [openPanelRef setDelegate: nil]; in the "//Missed something here".
Still I was wondering, System should not have send some message to the delegate once the dialog is dismissed.
That's strange behavior.
-Sanyam
From: Jens Alfke [mailto:email@hidden]
Sent: Friday, August 12, 2011 9:20 AM
To: Sanyam Jain
Cc: email@hidden
Subject: Re: Application crashes after launching Open/Save dialogs
On Aug 8, 2011, at 2:34 AM, Sanyam Jain wrote:
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x92dd3eec objc_msgSend + 44
A crash in objc_msgsend means a message was sent to a bad object pointer. Usually this means the object has already been dealloced and so its memory is garbage. (You can read up on NSZombieEnabled in the docs, for a general technique to debug this.)
2 com.apple.CoreFoundation 0x93c4e793 __CFXNotificationPost + 947
3 com.apple.CoreFoundation 0x93c4e19a _CFXNotificationPostNotification + 186
>From this you can deduce that a notification is being delivered. So what's going on is that one of your objects registered for NSNotifications, but forgot to remove itself as an observer in its -dealloc method, so the NSNotificationCenter still has a dangling pointer to it.
11 com.apple.Foundation 0x918ad669 -[NSNotificationCenter postNotificationName:object:] + 56
12 com.apple.AppKit 0x93ea151a -[NSTableView _enableSelectionPostingAndPost] + 509
13 com.apple.AppKit 0x93eacc17 -[NSTableView selectRowIndexes:byExtendingSelection:] + 168
...And from this, it looks like the notification is posted because a table view's selection changed.
>From this you ought to be able to figure out what class the bug is in and fix it. The rule of thumb is that in ANY class where you register self as an observer with an NSNotificationCenter, you MUST remove self as an observer in the -dealloc method.
-Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden