Re: NSFontPanel swamping the responder chain (and crashing)
Re: NSFontPanel swamping the responder chain (and crashing)
- Subject: Re: NSFontPanel swamping the responder chain (and crashing)
- From: Graham Cox <email@hidden>
- Date: Thu, 21 May 2015 14:53:35 +1000
> On 21 May 2015, at 2:41 pm, Quincey Morris <email@hidden> wrote:
>
> It looks to me like the problem is that the NSWindowController’s “document” property is still set to the NSDocument object that was just deallocated. I'm surprised to see that the “document” property is ‘assign’ rather than ‘strong’ (guess I never had a reason to look before).
I presume because the document owns its window controllers this must be weak to avoid a retain cycle.
> I don’t know if something in the NSDocument or NSWindowController machinery is supposed to set “document” back to nil when the document closes, or when, but apparently the fonts panel is causing traversal of the action event queue in a timing window before that’s occurred. It then crashes because the window controller is trying to make the (non-existent) document look like it’s in the responder chain. This is a stale pointer problem, not an overrelease problem, AFAICT.
Right. Forgive my sluggishness but I (eventually) arrived at this conclusion as well.
> You might be able to work around it by forcibly setting “document” to nil in the window controller (say) when the window is closing, though I don’t know what else that might interfere with.
I have tried that, but the problem persists.
That makes me wonder whether the window here is NOT the document’s main window, but the Save Panel? Maybe a sandboxed save panel (being the bizarre object it is) keeps a reference to the document it was attached to, and that is what is stale? Is there a way to reveal the address/identity of a given object in Instruments? I see the NSWindow method in the stack trace, but it doesn’t tell me which window.
—Graham
_______________________________________________
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