Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
- Subject: Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
- From: Jonathan Mitchell <email@hidden>
- Date: Wed, 30 Aug 2017 18:52:14 +0100
> On 30 Aug 2017, at 18:30, Quincey Morris
> <email@hidden> wrote:
>
> On Aug 30, 2017, at 06:18 , Jonathan Mitchell <email@hidden
> <mailto:email@hidden>> wrote:
>>
>> My documents have a lot of variable user cancellable activity that must run
>> prior to document closure regardless of whether the document is dirty or not.
>
>> My solution is to run a termination preflight that processes my clean
>> documents prior to allowing actual termination,
>
>
> Instead, the “applicationWillTerminate:” override of your app delegate seems
> like the right place, especially because it explicitly permits you to delay
> terminate while you do stuff, without having to run the run loop manually.
> That’s the *point* of the “applicationWillTerminate:” mechanism.
Thanks for the thoughts.
Using the applicationWillTerminate is probably a less hacky approach like you
say but it would mean refactoring to accommodate this one troublesome situation
- I would likely still need to retain the code that handles normal document
closing as well.
I am not sure that the NSApp -terminate: override is such an issue as the
problem only occurs when -terminate: is called. If another termination method
appears on the scene it will likely have its own foibles.
The doc close logic is quite tricky with copies of the NSDocument instance
being sent to both local and remote URLs. Getting it all to hang together at
termination in a way that integrates with the NSDocument architecture is
challenging.
As you say running the loop manually mimics what applicationWillTerminate tries
to achieve in the first place.
I will keep an eye on how the preflight code works out in the knowledge that I
can fall back to an “applicationWillTerminate” style approach.
_______________________________________________
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