Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2017-08-30 Thread Jonathan Mitchell
> On 30 Aug 2017, at 18:30, Quincey Morris > wrote: > > On Aug 30, 2017, at 06:18 , Jonathan Mitchell > wrote: >> >> My documents have a lot of variable user cancellable activity that must run >> prior

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2017-08-30 Thread Quincey Morris
On Aug 30, 2017, at 06:18 , Jonathan Mitchell 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

NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2017-08-30 Thread Jonathan Mitchell
This is one from the archives: https://lists.apple.com/archives/cocoa-dev/2012/Jul/msg00740.html In short NSDocument -canCloseDocumentWithDelegate::: gets called on documents when closing the document window but only for dirty documents when closing the app via NSApp -terminate: (i.e.: the

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2012-07-24 Thread Markus Spoettl
On 7/23/12 6:27 PM, Markus Spoettl wrote: On 7/23/12 5:42 PM, Fritz Anderson wrote: Perhaps I'm missing something — is writing the preferences file very time-consuming? If not, why not write it whether you need to or not? Or whenever a preferences value changes, which is what you'd do with

NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2012-07-23 Thread Markus Spoettl
Hello, when I close my document window without terminating the application, -canCloseDocumentWithDelegate::: is called, independent of whether the document is dirty. When I quit the application, -canCloseDocumentWithDelegate::: is only called if the document reports it is dirty. If it is

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2012-07-23 Thread Fritz Anderson
Perhaps I'm missing something — is writing the preferences file very time-consuming? If not, why not write it whether you need to or not? Or whenever a preferences value changes, which is what you'd do with NSUserDefaults? — F On 23 Jul 2012, at 10:12 AM, Markus Spoettl wrote: My

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2012-07-23 Thread Kevin Perry
I can't really recommend an approach that essentially lies about the dirty state of a document. If you have something to write into the document bundle, then the document is dirty and it should be declared so with the available NSDocument APIs. If the existing APIs don't meet your needs for

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2012-07-23 Thread Kyle Sluder
On Jul 23, 2012, at 8:12 AM, Markus Spoettl ms_li...@shiftoption.com wrote: Are there better options to do a last-minute save? I do not want to change the design, meaning I don't want preferences to contribute to the change count state or even worse be undoable. Plus I do want the

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2012-07-23 Thread Markus Spoettl
On 7/23/12 5:42 PM, Fritz Anderson wrote: Perhaps I'm missing something — is writing the preferences file very time-consuming? If not, why not write it whether you need to or not? Or whenever a preferences value changes, which is what you'd do with NSUserDefaults? Thanks for your suggestion.

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2012-07-23 Thread Kyle Sluder
On Jul 23, 2012, at 9:06 AM, Kevin Perry kpe...@apple.com wrote: I can't really recommend an approach that essentially lies about the dirty state of a document. If you have something to write into the document bundle, then the document is dirty and it should be declared so with the available

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2012-07-23 Thread Markus Spoettl
On 7/23/12 6:06 PM, Kevin Perry wrote: I can't really recommend an approach that essentially lies about the dirty state of a document. If you have something to write into the document bundle, then the document is dirty and it should be declared so with the available NSDocument APIs. If the

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2012-07-23 Thread Markus Spoettl
On 7/23/12 6:22 PM, Kyle Sluder wrote: I don't have my crazy autosave flowchart handy, but I *think* you should be able to simply override -hasUnautosavedChanges to return YES if either super returns YES or if your preferences file needs to be saved. -autosaveWithImplicitCancellability:: is

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2012-07-23 Thread Kevin Perry
On Jul 23, 2012, at 10:51 AM, Markus Spoettl ms_li...@shiftoption.com wrote: On 7/23/12 6:22 PM, Kyle Sluder wrote: I don't have my crazy autosave flowchart handy, but I *think* you should be able to simply override -hasUnautosavedChanges to return YES if either super returns YES or if your

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2012-07-23 Thread Markus Spoettl
On 7/23/12 9:34 PM, Kevin Perry wrote: If there would be a way to tell NSDocument to forgo asking whether to save a document if -isDocumentEdited returned YES, and instead just save it, that would be a solution. All I want is a silent save, when only preferences need to be saved (since I'm using