Fixed potential memory leaks on OS X

And renamed create* methods to new* to follow more closely Objective-C
naming convention regarding memory management.
This commit is contained in:
Marco Antognini 2014-05-23 12:10:53 +02:00 committed by Lukas Dürrenberger
parent 1dae89a8e0
commit 4f2c6c4489
3 changed files with 9 additions and 9 deletions

View File

@ -58,29 +58,29 @@
NSMenu* mainMenu = [NSApp mainMenu]; NSMenu* mainMenu = [NSApp mainMenu];
if (mainMenu != nil) if (mainMenu != nil)
return; return;
mainMenu = [[NSMenu alloc] initWithTitle:@""]; mainMenu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
[NSApp setMainMenu:mainMenu]; [NSApp setMainMenu:mainMenu];
// Application Menu (aka Apple Menu) // Application Menu (aka Apple Menu)
NSMenuItem* appleItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""]; NSMenuItem* appleItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenu* appleMenu = [[SFApplication createAppleMenu] autorelease]; NSMenu* appleMenu = [[SFApplication newAppleMenu] autorelease];
[appleItem setSubmenu:appleMenu]; [appleItem setSubmenu:appleMenu];
// File Menu // File Menu
NSMenuItem* fileItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""]; NSMenuItem* fileItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenu* fileMenu = [[SFApplication createFileMenu] autorelease]; NSMenu* fileMenu = [[SFApplication newFileMenu] autorelease];
[fileItem setSubmenu:fileMenu]; [fileItem setSubmenu:fileMenu];
// Window menu // Window menu
NSMenuItem* windowItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""]; NSMenuItem* windowItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenu* windowMenu = [[SFApplication createWindowMenu] autorelease]; NSMenu* windowMenu = [[SFApplication newWindowMenu] autorelease];
[windowItem setSubmenu:windowMenu]; [windowItem setSubmenu:windowMenu];
[NSApp setWindowsMenu:windowMenu]; [NSApp setWindowsMenu:windowMenu];
} }
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
+(NSMenu*)createAppleMenu +(NSMenu*)newAppleMenu
{ {
// Apple menu is as follow: // Apple menu is as follow:
// //
@ -159,7 +159,7 @@
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
+(NSMenu*)createFileMenu +(NSMenu*)newFileMenu
{ {
// The File menu is as follow: // The File menu is as follow:
// //
@ -181,7 +181,7 @@
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
+(NSMenu*)createWindowMenu +(NSMenu*)newWindowMenu
{ {
// The Window menu is as follow: // The Window menu is as follow:
// //

View File

@ -188,7 +188,7 @@
[m_window setIgnoresMouseEvents:NO]; [m_window setIgnoresMouseEvents:NO];
// Create a master view containing our OpenGL view // Create a master view containing our OpenGL view
NSView* masterView = [[SFBlackView alloc] initWithFrame:windowRect]; NSView* masterView = [[[SFBlackView alloc] initWithFrame:windowRect] autorelease];
if (masterView == nil) if (masterView == nil)
{ {

View File

@ -216,7 +216,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 alloc] init] autorelease]];
// Create menus for the application (before finishing launching!) // Create menus for the application (before finishing launching!)
[SFApplication setUpMenuBar]; [SFApplication setUpMenuBar];