> On 21 May 2015, at 7:31 pm, Quincey Morris > <quinceymor...@rivergatesoftware.com> wrote: > > However, there is actually one more possibility: window.delegate. If that’s > set to the document rather than the window controller, I suppose that might > account for the crash. But I can’t imagine it would be.
Well, I was going to say that in fact my window’s delegate is the document, but that I set it to nil early on during the closure sequence, so that couldn’t be it. However, you got me thinking (finally!). So I set a breakpoint on -[NSWindow setDelegate:]. It’s called quite a lot, but one place it was called unexpectedly was in -[NSDocument prepareSavePanel:] - I set the save panel’s delegate to the document. I can’t remember why I did this - it’s ancient code, and looking at it now it doesn’t appear to be implementing any delegate methods of NSSavePanel. So I tried commenting it out - BINGO, crash gone. So the crash was indeed caused by the Save panel having a stale ref to the document. (I’m supposing that even though PowerBox is a separate process, presumably the local save panel sheet is an interface and proxy for it, so it exists within the local process). And just to verify this finding, if I add a -prepareSavePanel: method to my simple test app, I can reproduce the identical crash there. I’m thinking that could be worth a radar, because it’s pretty easy to forget to remove that reference from the save panel (especially as in the modern block-based world, what the save panel calls is mostly internal to NSDocument and there isn’t a very obvious place to undo the -prepareSavePanel: work). So it looks as if the mystery is solved, subject to mopping up and checking that there’s no needed functionality that requires the save panel’s delegate to be my doc. Realising how simple this is, I’m wondering why it’s taken me so long to track this down. Basic dumbness, probably. Anyway, thanks for all your help, above and beyond for sure. —Graham _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com