Re: Temporarily disabling autosave
Re: Temporarily disabling autosave
- Subject: Re: Temporarily disabling autosave
- From: Mike Abdullah <email@hidden>
- Date: Sat, 20 Apr 2013 14:02:19 +0100
On 19 Apr 2013, at 21:04, Steve Mills <email@hidden> wrote:
> On Apr 19, 2013, at 14:37:11, Mike Abdullah <email@hidden> wrote:
>
>> Why, what's wrong with cancelling a save?
>
> It just seems icky. Who knows what behavior this will cause in the future? I just tried this approach, and it works the same as when I tried returning NO from hasUnautosavedChanges; it successfully prevents the autosave from happening, but then no other autosaves happen after that. I have to completely close the document and reopen before autosaves happen again. I even tried reverting with no luck. This leads me to believe that the autosave dirty state is getting out of whack if the save doesn't happen as planned. Any ideas?
Well that's odd. As an experiment, I whacked this into my NSDocument subclass:
- (BOOL)writeToURL:(NSURL *)inURL
ofType:(NSString *)typeName
forSaveOperation:(NSSaveOperationType)saveOp
originalContentsURL:(NSURL *)originalContentsURL
error:(NSError **)error
{
if (self.autosavingIsImplicitlyCancellable)
{
NSLog(@"Cancelling autosave");
if (error) *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:nil];
return NO;
}
I opened a document, made a change, then left it idling. I can see in the console a steady procession of "Cancelling autosave" messages, roughly every 15 seconds. So if I were to make the cancellation conditional on something else as well, such as whether playback is in progress, I'd expect it to work properly.
Seriously, Apple's engineers put this system in for a reason. As best I can tell, that reason is cases like yours.
_______________________________________________
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