On Apr 12, 2013, at 16:16:53, Quincey Morris 
<[email protected]> wrote:

> You can just override "autosavesInPlace" to return NO, to turn off the new 
> behavior. 
> 
> It's also possible that just overriding "autosavesDrafts" to return NO might 
> disable the untitled document behavior, if that's all you need, but the 
> "drafts" behavior is a bit hard to follow from the documentation.

I don't see an autosavesDrafts method anywhere. Ah, I just found it in 
NSDocument. Strange that searching for that term in the help window didn't find 
it.

I have the following overrides in my NSDocument subclass:

+(BOOL) preservesVersions
{
        return NO;
}

+(BOOL) autosavesDrafts
{
        return NO;
}

- (BOOL)hasUnautosavedChanges
{
        // We don't do Cocoa autosaving - we do our own:
        return NO;
}       

- (NSString*)autosavingFileType
{
        // Another way to prevent Cocoa's autosaving:
        return nil;
}

Note in my original message I said "kill" not "quit". I meant if I kill the app 
from the debugger or force quit. In this case, if I had an dirty untitled 
document open, the system will create new empty documents when I launch again. 
How can I prevent this? The data was never saved anywhere, so opening a new 
document is the wrong thing for the OS to do. The stack is shown below. I don't 
see any method I can override to prevent this. I could install my own event 
handler for kAEOpenApplication, but I don't know everything the default handler 
does for this event, so I'd probably lose lots of standard behavior, and it 
seems like overkill.

#0      0x027b237a in -[FCMacDocumentController 
openUntitledDocumentAndDisplay:error:]
#1      0x99ed1998 in -[NSDocumentController 
_openUntitledDocumentOfType:andDisplay:error:] ()
#2      0x99ed9834 in -[NSDocumentController 
_restorePersistentDocumentWithState:completionHandler:] ()
#3      0x99eda17c in __block_global_27 ()
#4      0x99ed1ea6 in -[NSDocumentController 
_waitForAsyncOpeningOrPrintingToFinishThenContinue:] ()
#5      0x99ed9ea3 in __76+[NSDocumentController 
restoreWindowWithIdentifier:state:completionHandler:]_block_invoke_0 ()
#6      0x99b7cfee in -[NSApplication _whenReopeningIsAllowedDo:] ()
#7      0x99ed9dec in +[NSDocumentController 
restoreWindowWithIdentifier:state:completionHandler:] ()
#8      0x99ac641d in -[NSApplication(NSPersistentUISupport) 
restoreWindowWithIdentifier:state:completionHandler:] ()
#9      0x99ac5d3a in -[NSApplication(NSPersistentUISupport) 
_restoreWindowWithRestoration:handler:] ()
#10     0x99ac48cd in -[NSPersistentUIManager 
restoreAllPersistentStateRegisteringAsReadyWhenDone:completionHandler:] ()
#11     0x99b7af28 in -[NSApplication 
_reopenWindowsAsNecessaryIncludingRestorableState:registeringAsReady:completionHandler:]
 ()
#12     0x99b7adf5 in -[NSApplication(NSAppleEventHandling) 
_reopenWindowsIfNecessaryWithAppleEvent:completionHandler:] ()
#13     0x99b7acfa in -[NSApplication(NSAppleEventHandling) 
_handleAEOpenEvent:] ()
#14     0x99b7a824 in -[NSApplication(NSAppleEventHandling) 
_handleCoreEvent:withReplyEvent:] ()
#15     0x915b1628 in -[NSObject performSelector:withObject:withObject:] ()
#16     0x92f2c73a in __76-[NSAppleEventManager 
setEventHandler:andSelector:forEventClass:andEventID:]_block_invoke_0 ()
#17     0x92f2c291 in -[NSAppleEventManager 
dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()
#18     0x92f2c08e in _NSAppleEventManagerGenericHandler ()
#19     0x90523a35 in aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned 
long, unsigned char*) ()
#20     0x904f8fbe in dispatchEventAndSendReply(AEDesc const*, AEDesc*) ()
#21     0x904f8e7d in aeProcessAppleEvent ()
#22     0x90170c58 in AEProcessAppleEvent ()
#23     0x99b76d4d in _DPSNextEvent ()
#24     0x99b761dc in -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#25     0x99b6c63c in -[NSApplication run] ()
#26     0x99b0f666 in NSApplicationMain ()
#27     0x01309368 in main


--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157



_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to