From a4a7f77ef126f57906b16a09bef70dfc040e1b1c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 12 Nov 2025 09:31:31 +0530 Subject: [PATCH] Use __block rather than __weak since we are in manual ref counting regime --- glfw/cocoa_init.m | 3 ++- glfw/cocoa_window.m | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/glfw/cocoa_init.m b/glfw/cocoa_init.m index 296949eed..8a6ae6dfa 100644 --- a/glfw/cocoa_init.m +++ b/glfw/cocoa_init.m @@ -453,8 +453,9 @@ - (void)observeValueForKeyPath:(NSString *)keyPath if ([keyPath isEqualToString:@"effectiveAppearance"]) { // The initial call (from NSKeyValueObservingOptionInitial) might happen on a background thread. // Dispatch to the main thread to be safe, especially if updating UI. + __block __typeof__(self) weakSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ - [self handleAppearanceChange]; + [weakSelf handleAppearanceChange]; }); } } else { diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index b4c952f13..7c0e1ab38 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -2330,8 +2330,9 @@ void _glfwPlatformShowWindow(_GLFWwindow* window, bool move_to_active_screen) NSWindowCollectionBehavior old = nw.collectionBehavior; nw.collectionBehavior = (old & !NSWindowCollectionBehaviorCanJoinAllSpaces) | NSWindowCollectionBehaviorMoveToActiveSpace; [nw orderFront:nil]; + __block __typeof__(nw) weakSelf = nw; dispatch_async(dispatch_get_main_queue(), ^{ - nw.collectionBehavior = old; + weakSelf.collectionBehavior = old; }); } }