Re: NSTableView is messaging zombie delegate
Re: NSTableView is messaging zombie delegate
- Subject: Re: NSTableView is messaging zombie delegate
- From: Quincey Morris <email@hidden>
- Date: Sun, 08 May 2016 13:00:13 -0700
- Feedback-id: 167118m:167118agrif8a:167118seNg_fO8cX:SMTPCORP
On May 8, 2016, at 12:19 , Matthew LeRoy <email@hidden> wrote:
>
> Unfortunately, setting the table view’s delegate to nil during tear-down (either in -windowWillClose: or in NSViewController’s -dealloc) doesn’t seem to fix the issue. I still get random but regularly reproducible crashes, with the same stack trace.
>
> Any other ideas?
It’s the right idea, but you should cast your net a bit wider.
If you look at your backtrace again, you’ll see that it crashed doing something with rows. It’s as likely trying to message your data source as your delegate. You should nil that as well. Note that it’s not necessarily that any particular object has or hasn't been deallocated, but there’s a whole network of objects that may have now-invalid references somewhere. (In this case, it looks like the reference to a table cell view that’s crashing.)
Also consider delegate (and similar) references to view controllers and window controllers. IIRC, the window itself may not be deallocated immediately after being closed, because it’s kept alive until the window server (a difference process) gets around to cleaning up after it, and so it might take a few iterations of your run loop before the window object goes away. That in turn might keep alive other controller/delegate objects that your app has otherwise finished with.
The trick to solving this is to find just the right weak reference to nil.
The other area to pay attention to is the possibility that you’ve created some other retain cycles between objects that keep them alive longer than necessary. That may in turn cause them to follow now-invalid weak references.
_______________________________________________
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