From 5052b2d7e0c59f2f4352e4feef67f5d26c1468e7 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 20 Oct 2014 22:41:58 -0700 Subject: [PATCH] Create an autorelease pool in glfwPostEmptyEvent. This prevents leaking NSEvent objects. Closes #372. --- README.md | 1 + src/cocoa_window.m | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index e2121c5a..0cf76d75 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,7 @@ skills. - Ricardo Vieira - Simon Voordouw - Torsten Walluhn + - Patrick Walton - Jay Weisskopf - Frank Wille - yuriks diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 463c02c6..dd7b012f 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1206,6 +1206,7 @@ void _glfwPlatformWaitEvents(void) void _glfwPlatformPostEmptyEvent(void) { + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSEvent* event = [NSEvent otherEventWithType:NSApplicationDefined location:NSMakePoint(0, 0) modifierFlags:0 @@ -1216,6 +1217,7 @@ void _glfwPlatformPostEmptyEvent(void) data1:0 data2:0]; [NSApp postEvent:event atStart:YES]; + [pool drain]; } void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)