From 519363930a979fafeaced303e76c5e036a895d81 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 7 Jul 2021 04:34:19 +0900 Subject: [PATCH] internal/uidriver/glfw: Bug fix: Memory leak in Objective-C code Use an autorelease pool block. Closes #1698 --- internal/uidriver/glfw/ui_darwin.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/internal/uidriver/glfw/ui_darwin.go b/internal/uidriver/glfw/ui_darwin.go index 87578bba1..bbf879013 100644 --- a/internal/uidriver/glfw/ui_darwin.go +++ b/internal/uidriver/glfw/ui_darwin.go @@ -23,21 +23,23 @@ package glfw // #import // // static void currentMonitorPos(uintptr_t windowPtr, int* x, int* y) { -// NSScreen* screen = [NSScreen mainScreen]; -// if (windowPtr) { -// NSWindow* window = (NSWindow*)windowPtr; -// if ([window isVisible]) { -// // When the window is visible, the window is already initialized. -// // [NSScreen mainScreen] sometimes tells a lie when the window is put across monitors (#703). -// screen = [window screen]; +// @autoreleasepool { +// NSScreen* screen = [NSScreen mainScreen]; +// if (windowPtr) { +// NSWindow* window = (NSWindow*)windowPtr; +// if ([window isVisible]) { +// // When the window is visible, the window is already initialized. +// // [NSScreen mainScreen] sometimes tells a lie when the window is put across monitors (#703). +// screen = [window screen]; +// } // } +// NSDictionary* screenDictionary = [screen deviceDescription]; +// NSNumber* screenID = [screenDictionary objectForKey:@"NSScreenNumber"]; +// CGDirectDisplayID aID = [screenID unsignedIntValue]; +// const CGRect bounds = CGDisplayBounds(aID); +// *x = bounds.origin.x; +// *y = bounds.origin.y; // } -// NSDictionary* screenDictionary = [screen deviceDescription]; -// NSNumber* screenID = [screenDictionary objectForKey:@"NSScreenNumber"]; -// CGDirectDisplayID aID = [screenID unsignedIntValue]; -// const CGRect bounds = CGDisplayBounds(aID); -// *x = bounds.origin.x; -// *y = bounds.origin.y; // } // // static bool isNativeFullscreen() {