Moved the main Nib file loading from -finishLaunching to NSApplicationMain() in

order to match Cocoa behavior/documentation.

This makes easier to implement a custom AppKit main that works with both Cocoa 
and GNUstep.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30398 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Quentin Mathe 2010-05-16 13:56:50 +00:00
parent b90707ed47
commit 5285361395
2 changed files with 15 additions and 11 deletions

View file

@ -33,6 +33,7 @@
#include "AppKit/NSApplication.h"
#include "AppKit/NSBitmapImageRep.h"
#include "AppKit/NSNibLoading.h"
#include "AppKit/NSEvent.h"
#include "AppKit/NSGraphicsContext.h"
#include "AppKit/NSGraphics.h"
@ -50,6 +51,7 @@ int
NSApplicationMain(int argc, const char **argv)
{
NSDictionary *infoDict;
NSString *mainModelFile;
NSString *className;
Class appClass;
CREATE_AUTORELEASE_POOL(pool);
@ -70,8 +72,20 @@ NSApplicationMain(int argc, const char **argv)
NSLog(@"Bad application class '%@' specified", className);
appClass = [NSApplication class];
}
[appClass sharedApplication];
[[appClass sharedApplication] run];
mainModelFile = [infoDict objectForKey: @"NSMainNibFile"];
if (mainModelFile != nil && [mainModelFile isEqual: @""] == NO)
{
if ([NSBundle loadNibNamed: mainModelFile owner: NSApp] == NO)
{
NSLog (_(@"Cannot load the main model file '%@'"), mainModelFile);
}
}
RECREATE_AUTORELEASE_POOL(pool);
[NSApp run];
DESTROY(NSApp);

View file

@ -949,7 +949,6 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
NSBundle *mainBundle = [NSBundle mainBundle];
NSDictionary *infoDict = [mainBundle infoDictionary];
NSDocumentController *sdc;
NSString *mainModelFile;
NSString *appIconFile;
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
NSString *filePath;
@ -992,15 +991,6 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
[self setApplicationIconImage: image];
[self _appIconInit];
mainModelFile = [infoDict objectForKey: @"NSMainNibFile"];
if (mainModelFile != nil && [mainModelFile isEqual: @""] == NO)
{
if ([NSBundle loadNibNamed: mainModelFile owner: self] == NO)
{
NSLog (_(@"Cannot load the main model file '%@'"), mainModelFile);
}
}
/* post notification that launch will finish */
[nc postNotificationName: NSApplicationWillFinishLaunchingNotification
object: self];