diff -r 59942ee67d15 AppKit/NSApplication.m --- a/AppKit/NSApplication.m Fri Sep 03 14:44:12 2010 -0400 +++ b/AppKit/NSApplication.m Tue Sep 07 18:15:00 2010 -0400 @@ -418,6 +418,10 @@ needsUntitled = [_delegate applicationShouldOpenUntitledFile: self]; } + if(needsUntitled && _delegate && [_delegate respondsToSelector: @selector(applicationOpenUntitledFile:)]) { + needsUntitled = ![_delegate applicationOpenUntitledFile: self]; + } + if(needsUntitled && controller && ![controller documentClassForType:[controller defaultType]]) { needsUntitled = NO; } @@ -472,11 +476,17 @@ -(void)run { - NSAutoreleasePool *pool=[NSAutoreleasePool new]; - [self finishLaunching]; - [pool release]; - - _isRunning=YES; + static BOOL didlaunch = NO; + NSAutoreleasePool *pool; + + _isRunning=YES; + + if (!didlaunch) { + didlaunch = YES; + pool=[NSAutoreleasePool new]; + [self finishLaunching]; + [pool release]; + } do { pool = [NSAutoreleasePool new]; diff -r 59942ee67d15 AppKit/NSDocument.m --- a/AppKit/NSDocument.m Fri Sep 03 14:44:12 2010 -0400 +++ b/AppKit/NSDocument.m Tue Sep 07 18:15:00 2010 -0400 @@ -21,6 +21,8 @@ @implementation NSDocument +static int untitled_document_number = 0; + +(NSArray *)readableTypes { int i; NSArray *knownDocTypes = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDocumentTypes"]; @@ -98,7 +100,7 @@ _fileURL=nil; _fileType=nil; _changeCount=0; - _untitledNumber=0; + _untitledNumber=untitled_document_number++; _hasUndoManager=YES; _activeEditors=[NSMutableArray new]; } @@ -340,7 +342,7 @@ { if(_fileURL==nil) { - if(_untitledNumber > 1) + if(_untitledNumber != 0) return [NSString stringWithFormat:@"Untitled %d", _untitledNumber]; else return @"Untitled";