mirror of
https://github.com/glfw/glfw.git
synced 2024-11-14 02:31:46 +00:00
Fixed lifetime management of application delegate.
This commit is contained in:
parent
d459145d28
commit
1634742177
@ -228,11 +228,11 @@ void _glfwPlatformTerminate(void)
|
|||||||
_glfw.ns.eventSource = NULL;
|
_glfw.ns.eventSource = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
id delegate = [NSApp delegate];
|
if (_glfw.ns.delegate)
|
||||||
if (delegate)
|
|
||||||
{
|
{
|
||||||
[delegate release];
|
|
||||||
[NSApp setDelegate:nil];
|
[NSApp setDelegate:nil];
|
||||||
|
[_glfw.ns.delegate release];
|
||||||
|
_glfw.ns.delegate = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
[_glfw.ns.autoreleasePool release];
|
[_glfw.ns.autoreleasePool release];
|
||||||
|
@ -76,6 +76,7 @@ typedef struct _GLFWwindowNS
|
|||||||
typedef struct _GLFWlibraryNS
|
typedef struct _GLFWlibraryNS
|
||||||
{
|
{
|
||||||
CGEventSourceRef eventSource;
|
CGEventSourceRef eventSource;
|
||||||
|
id delegate;
|
||||||
id autoreleasePool;
|
id autoreleasePool;
|
||||||
id cursor;
|
id cursor;
|
||||||
|
|
||||||
|
@ -794,15 +794,15 @@ static GLboolean initializeAppKit(void)
|
|||||||
|
|
||||||
// There can only be one application delegate, but we allocate it the
|
// There can only be one application delegate, but we allocate it the
|
||||||
// first time a window is created to keep all window code in this file
|
// first time a window is created to keep all window code in this file
|
||||||
id delegate = [[GLFWApplicationDelegate alloc] init];
|
_glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
|
||||||
if (delegate == nil)
|
if (_glfw.ns.delegate == nil)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Cocoa: Failed to create application delegate");
|
"Cocoa: Failed to create application delegate");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
[NSApp setDelegate:delegate];
|
[NSApp setDelegate:_glfw.ns.delegate];
|
||||||
[NSApp run];
|
[NSApp run];
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
|
Loading…
Reference in New Issue
Block a user