Re: Temporarily disabling autosave
Re: Temporarily disabling autosave
- Subject: Re: Temporarily disabling autosave
- From: Mike Abdullah <email@hidden>
- Date: Tue, 23 Apr 2013 23:39:17 +0100
On 23 Apr 2013, at 15:19, Jerry Krinock wrote:
>
> On 2013 Apr 22, at 21:42, Steve Mills <email@hidden> wrote:
>
>> [-setAutosavingDelay:0.0] didn't work.
>
> OK, then. I retract my surprise.
>
>> The pause mechanism is something in our own code - a bool that says it's paused (it's actually an integer so it can be incremented/decremented in a nested fashion).
>
> That's fine, but your code is not running the show in Lion autosave. The holy grail we're discussing here is a method to tell Cocoa "Stop sending me autosave requests (-[NSDocument autosaveWithImplicitCancellability:completionHandler:]) until I tell you to start again". I believe, as I have from the beginning, that there is no such method. If your NSDocument subclass returns YES to +autosavesInPlace, you *will* get (-[NSDocument autosaveWithImplicitCancellability:completionHandler:]) at arbitrary times.
>
>> I check this value in writeToURL and hasUnautosavedChanges.
>
> I've never tried -hasUnautosavedChanges, because it's another "Tiger" autosave method, available since Mac OS X 10.4. Do you ever get that message? If so, then returning NO might pause -[NSDocument autosaveWithImplicitCancellability:completionHandler:], which is the holy grail here. If that works, I shall drop my jaw again.
-hasUnautosavedChanges continues to be applicable to all (auto)saving models.
I caution against overriding it since:
A) Your override is likely a lie to the system when you get down to it. This might upset the state for other bits of the system
B) A perfectly good system for backing out of non-essential autosaves already exists, and should be used instead
If you read the docs for -autosaveWithImplicitCancellability:completionHandler: *its* implementation calls -hasUnautosavedChanges. It will back out without doing any work should the document claim not to have any unautosaved changes.
I suspect that if you do override -hasUnautosavedChanges, a call to -scheduleAutosaving would be needed — at least under some circumstances — to restart autosave when you’re ready.
_______________________________________________
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