diff --git a/ChangeLog b/ChangeLog index 0dde1fd4d..52e965ae7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-10-17 Wolfgang Lux + + * Source/NSApplication.m (-finishLaunching): Open a new document + by default when a document based application is started and there + is no file to open. + 2009-10-17 Richard Frith-Macdonald * Source/NSWindow.m: diff --git a/Source/NSApplication.m b/Source/NSApplication.m index b49e8984c..5bb5f62e6 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -1129,14 +1129,30 @@ static NSSize scaledIconSizeForSize(NSSize imageSize) [_listener application: self printFile: filePath]; [self terminate: self]; } - else if (!didAutoreopen && ![defs boolForKey: @"autolaunch"] - && [_delegate respondsToSelector: - @selector(applicationShouldOpenUntitledFile:)] - && ([_delegate applicationShouldOpenUntitledFile: self]) - && [_delegate respondsToSelector: - @selector(applicationOpenUntitledFile:)]) + else if (!didAutoreopen && ![defs boolForKey: @"autolaunch"]) { - [_delegate applicationOpenUntitledFile: self]; + if ([_delegate respondsToSelector: + @selector(applicationShouldOpenUntitledFile:)]) + { + if ([_delegate applicationShouldOpenUntitledFile: self] + && [_delegate respondsToSelector: + @selector(applicationOpenUntitledFile:)]) + { + [_delegate applicationOpenUntitledFile: self]; + } + } + else if ([NSDocumentController isDocumentBasedApplication]) + { + NSError *err; + NSDocumentController *sdc = + [NSDocumentController sharedDocumentController]; + + if ([sdc openUntitledDocumentAndDisplay: YES error: &err] == nil && + [sdc presentError: err] == NO) + { + [self terminate: self]; + } + } } }