Re: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?
Re: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?
- Subject: Re: canAsynchronouslyWriteToURL:ofType:forSaveOperation: Prevent Quit?
- From: Kyle Sluder <email@hidden>
- Date: Sun, 20 Apr 2014 22:26:26 -0700
On Apr 20, 2014, at 10:11 PM, Trygve Inda <email@hidden> wrote:
>> On Apr 20, 2014, at 6:58 PM, Trygve Inda <email@hidden> wrote:
>>
>>>>> On Apr 20, 2014, at 4:29 PM, Trygve Inda <email@hidden> wrote:
>>>>>
>>>>> A small correction... This seems to only happen when I do a "Save As". If
>>>>> the file is dirty and I do a "Save", the "file is dirty warning" catches
>>>>> the
>>>>> quit.
>>>>
>>>> Does the bad behavior also apply to Save if you turn off the “Close all
>>>> windows when quitting apps” option in System Preferences?
>>>>
>>>> --Kyle Sluder
>>>
>>> Yes - it quits regardless of that setting.
>>
>> What I'm asking is whether turning that setting off causes Save to exhibit the
>> same behavior as Save As—in other words, are you only seeing a difference in
>> behavior because your machine happens to be configured in a way that involves
>> NSApplication's consult-the-dirty-documents codepath?
>>
>> And in that vein, have you subclasses NSApplication at all, implemented
>> -[<NSApplicationDelegate> applicationShouldTerminate:] and/or sent
>> -replyToApplicationShouldTerminate: to NSApp, or taken over termination
>> yourself?
>>
>> --Kyle Sluder
>
> Changing the System prefs checkbox does not affect Save or Save As.
>
> In a Save the dirty mark is not cleared until the file is written, thus it
> asks before quitting about saving the document.
Well, the reason I asked about that checkbox is that if it's unchecked, AppKit might not look at dirty windows *at all* during termination. Unchecking that box actually has the effect of telling AppKit to autosave all documents at Quit and restore them on the next launch. (This is the behavior AppKit performs when background-terminating or being asked to terminate because the system is logging out—assuming the user also chose “Restore windows at login” on the logout confirmation panel.)
Come to think of it, does your app adopt Lion Autosave?
>
> My app delegate for termination looks like:
>
> -(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication
> *)theApplication
> {
> return NO;
> }
>
>
> -(void)applicationWillTerminate:(NSNotification *)aNotification
> {
> [self quitApplicationWithBundleIdentifier:myHelperAppBundleIdentifier];
>
> [[NSUserDefaults standardUserDefaults] synchronize];
> }
>
>
> -(void)quitApplicationWithBundleIdentifier:(NSString *)identifier
> {
> NSArray* appArray = [NSRunningApplication
> runningApplicationsWithBundleIdentifier:identifier];
>
> for (NSRunningApplication* process in appArray)
> [process terminate];
> }
Hmmm… I’m assuming these are not the problem. But just for laughs, maybe try taking this code out and see if you have the same issue.
Otherwise, it might be time to file a Radar and/or a DTS incident.
--Kyle Sluder
_______________________________________________
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