mirror of
https://github.com/glfw/glfw.git
synced 2025-06-15 12:12:16 +00:00
Fixed memory leak in cocoa _glfwPlatformGetKeyName
This commit is contained in:
parent
9c68e11f2f
commit
363ec64321
@ -108,6 +108,7 @@ typedef struct _GLFWlibraryNS
|
|||||||
GLboolean cursorHidden;
|
GLboolean cursorHidden;
|
||||||
|
|
||||||
char* clipboardString;
|
char* clipboardString;
|
||||||
|
char* keyName;
|
||||||
|
|
||||||
_GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1];
|
_GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1];
|
||||||
} _GLFWlibraryNS;
|
} _GLFWlibraryNS;
|
||||||
|
@ -1098,7 +1098,11 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
|||||||
|
|
||||||
const char* _glfwPlatformGetKeyName(int key)
|
const char* _glfwPlatformGetKeyName(int key)
|
||||||
{
|
{
|
||||||
// First try to translate virtual key mac os x style
|
// free temp keyname
|
||||||
|
free(_glfw.ns.keyName);
|
||||||
|
_glfw.ns.keyName = 0;
|
||||||
|
|
||||||
|
// Try to translate virtual key mac os x style
|
||||||
UInt16 vKey = 0;
|
UInt16 vKey = 0;
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
@ -1189,8 +1193,8 @@ const char* _glfwPlatformGetKeyName(int key)
|
|||||||
if (actualStringLength > 0 && status == noErr)
|
if (actualStringLength > 0 && status == noErr)
|
||||||
{
|
{
|
||||||
NSString* tempNS = [[NSString stringWithCharacters:unicodeString length:(NSUInteger)actualStringLength] uppercaseString];
|
NSString* tempNS = [[NSString stringWithCharacters:unicodeString length:(NSUInteger)actualStringLength] uppercaseString];
|
||||||
char* pTodoFree = strdup([tempNS UTF8String]);
|
_glfw.ns.keyName = strdup([tempNS UTF8String]);
|
||||||
return pTodoFree;
|
return _glfw.ns.keyName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user