Re: Telling Auto Save, No, I'm busy now

2011-08-09 Thread Jerry Krinock
On 2011 Aug 08, at 09:29, Kevin Perry wrote: You may be able to work around this problem by overriding -autosaveWithImplicitCancellability:completionHandler: instead (also?) and doing the same approach of delaying NSDocument's code until once you've completed the background work. Thank

Re: Telling Auto Save, No, I'm busy now

2011-08-08 Thread Kevin Perry
Ah, I did not foresee this. I really can't generally recommend calling -saveToURL:::error: instead of saveToURL:::completionHandler: because the latter does some important things that the former doesn't. Unfortunately, I think the problem you're seeing with the hang is insurmountable without

Re: Telling Auto Save, No, I'm busy now

2011-08-06 Thread Jerry Krinock
On 2011 Aug 04, at 08:30, Kevin Perry wrote: What Ken said. OK, I'm back. Had to fork my project since Block_copy()/release() is not available in 10.5 SDK. But it works now. See code below. Also, it might be more convenient to use NSBlockOperation or -addOperationWithBlock so the

Re: Telling Auto Save, No, I'm busy now

2011-08-04 Thread Jerry Krinock
On 2011 Aug 01, at 08:14, Kevin Perry wrote: Canceling an autosave when -autosavingIsImplicitlyCancellable returns NO will cause problems with file coordination. Thank you, Kevin. I believe you and Jens on this. Indeed, when I close a document window, its document receives a

Re: Telling Auto Save, No, I'm busy now

2011-08-04 Thread Ken Thomases
On Aug 4, 2011, at 8:54 AM, Jerry Krinock wrote: I'm getting a crash if I begin some operations and then hit the 'close' button on the window while the operations are in progress… I take the four parameters I receive in saveToURL:ofType:forSaveOperation:completionHandler: and put them

Re: Telling Auto Save, No, I'm busy now

2011-08-04 Thread Jerry Krinock
On 2011 Aug 04, at 07:53, Ken Thomases wrote: On Aug 4, 2011, at 8:54 AM, Jerry Krinock wrote: I'm getting a crash if I begin some operations and then hit the 'close' button on the window while the operations are in progress… I take the four parameters I receive in

Re: Telling Auto Save, No, I'm busy now

2011-08-04 Thread Kevin Perry
What Ken said. Also, it might be more convenient to use NSBlockOperation or -addOperationWithBlock so the function parameters (including the completion handler) are all captured correctly for you automatically. It's a lot more convenient than stashing things in an NSDictionary. Finally, I

Re: Telling Auto Save, No, I'm busy now

2011-08-01 Thread Kevin Perry
AppKit-initiated autosaves generally happen for two main reasons: the autosave timer, and file coordination. These are both initiated with -autosaveWithImplicitCancellability:completionHandler:. The implicitly cancelable flag indicates whether it's appropriate for an NSDocument subclass to

Re: Telling Auto Save, No, I'm busy now

2011-07-30 Thread Ken Thomases
On Jul 29, 2011, at 10:32 PM, Jerry Krinock wrote: With Auto Save enabled in a document, I find that Lion sometimes wants to break into a sequence of operations to do an Auto Save. What do you mean by break into or a sequence of operations? The frameworks are almost certainly not

Re: Telling Auto Save, No, I'm busy now

2011-07-30 Thread Jerry Krinock
On 2011 Jul 30, at 02:10, Ken Thomases wrote: On Jul 29, 2011, at 10:32 PM, Jerry Krinock wrote: With Auto Save enabled in a document, I find that Lion sometimes wants to break into a sequence of operations to do an Auto Save. What do you mean by break into or a sequence of operations?

Re: Telling Auto Save, No, I'm busy now

2011-07-30 Thread wadeslists
- (void)saveToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation completionHandler:(void (^)(NSError *errorOrNil))completionHandler { if (saveOperation == NSAutosaveInPlaceOperation) { if ([[[NSOperationQueue mainQueue]

Re: Telling Auto Save, No, I'm busy now

2011-07-30 Thread Jerry Krinock
On 2011 Jul 30, at 15:39, wadesli...@mac.com wrote: You're lying to the save machinery by saying that you have saved, when you have not. So NSFileCoordinator will then think your file is up to date, and let others read (or write) it. It could lead to all sorts of nasty behaviors… Thank

Re: Telling Auto Save, No, I'm busy now

2011-07-30 Thread Quincey Morris
On Jul 30, 2011, at 18:41, Jerry Krinock wrote: But it still seems that Apple should document the correct way to handle this situation. I can't help thinking that there was a (brief) section about this in the 2011 WWDC session video that I watched. If you don't want to be interrupted by an

Re: Telling Auto Save, No, I'm busy now

2011-07-30 Thread Jerry Krinock
On 2011 Jul 30, at 20:12, Quincey Morris wrote: I can't help thinking that there was a (brief) section about this in the 2011 WWDC session video that I watched. If you don't want to be interrupted by an Auto Save, If you haven't watched this video, it might be worth spending the 50

Re: Telling Auto Save, No, I'm busy now

2011-07-30 Thread Jens Alfke
On Jul 30, 2011, at 9:45 PM, Jerry Krinock wrote: Thank you, Quincey. I watched that a few weeks ago, and studied the part on Auto Save carefully. I think that what you are recalling is the ability to cancel an Auto Save after it is started, by returning NO in -writeToURL:ofType:error:.

Telling Auto Save, No, I'm busy now

2011-07-29 Thread Jerry Krinock
With Auto Save enabled in a document, I find that Lion sometimes wants to break into a sequence of operations to do an Auto Save. I haven't been able to find any recommendation of how to tell Auto Save No, I'm busy now. I just figured out how to do it by overriding saveToURL. It seems to