diff --git a/ChangeLog b/ChangeLog index efc82009a..ccdc1a282 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-10-13 Wolfgang Lux + + * Source/NSApplication.m (-finishLaunching): Open a new document + in a document based application when the delegate responds YES to + applicationShouldOpenUntitledFile: but does not implement + applicationOpenUntitledFile:. + 2010-10-08 Wolfgang Lux * Source/NSWindowController.m (-window): Send diff --git a/Source/NSApplication.m b/Source/NSApplication.m index d6627be53..82c572b8b 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -1134,24 +1134,34 @@ static NSSize scaledIconSizeForSize(NSSize imageSize) } else if (!didAutoreopen && ![defs boolForKey: @"autolaunch"]) { + // For document based applications we automatically open a fresh document + // unless denied by the delegate. For non-document based applications we + // open a fresh document only when requested by the delegate. + // Note: We consider an application document based if the shared document + // controller reports at least one editable type. + BOOL docBased = + [[sdc documentClassNames] count] > 0 && [sdc defaultType] != nil; + BOOL shouldOpen = docBased ? YES : NO; + if ([_delegate respondsToSelector: @selector(applicationShouldOpenUntitledFile:)]) { - if ([_delegate applicationShouldOpenUntitledFile: self] - && [_delegate respondsToSelector: - @selector(applicationOpenUntitledFile:)]) - { - [_delegate applicationOpenUntitledFile: self]; - } - } - else if ([[sdc documentClassNames] count] > 0 && [sdc defaultType] != nil) - { - NSError *err = nil; - - if ([sdc openUntitledDocumentAndDisplay: YES error: &err] == nil - && [sdc presentError: err] == NO) + shouldOpen = [_delegate applicationShouldOpenUntitledFile: self]; + } + if (shouldOpen) + { + if (docBased) { - [self terminate: self]; + NSError *err = nil; + if ([sdc openUntitledDocumentAndDisplay: YES error: &err] == nil) + { + [sdc presentError: err]; + } + } + else if ([_delegate respondsToSelector: + @selector(applicationOpenUntitledFile:)]) + { + [_delegate applicationOpenUntitledFile: self]; } } }