Fixed NSApplication not retaining its delegate

This commit is contained in:
Marco Antognini 2014-04-13 13:06:42 +02:00
parent 0d47056132
commit 324d4a18e7
3 changed files with 15 additions and 1 deletions

View File

@ -50,4 +50,10 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication; -(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication;
////////////////////////////////////////////////////////////
/// \brief Return a singleton instance of this class
///
////////////////////////////////////////////////////////////
+(id)instance;
@end @end

View File

@ -49,6 +49,14 @@
return YES; return YES;
} }
////////////////////////////////////////////////////////////
+(id)instance
{
static SFApplicationDelegate* singleton = nil;
if (singleton == nil)
singleton = [[SFApplicationDelegate alloc] init];
return singleton;
}
@end @end

View File

@ -139,7 +139,7 @@ void WindowImplCocoa::setUpProcess(void)
// Register an application delegate if there is none // Register an application delegate if there is none
if (![[SFApplication sharedApplication] delegate]) if (![[SFApplication sharedApplication] delegate])
[NSApp setDelegate:[[SFApplicationDelegate alloc] init]]; [NSApp setDelegate:[SFApplicationDelegate instance]];
// Create menus for the application (before finishing launching!) // Create menus for the application (before finishing launching!)
[SFApplication setUpMenuBar]; [SFApplication setUpMenuBar];