mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 12:51:05 +08:00
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:
parent
1dae89a8e0
commit
4f2c6c4489
@ -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:
|
||||||
//
|
//
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -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];
|
||||||
|
Loading…
Reference in New Issue
Block a user