Use __block rather than __weak since we are in manual ref counting regime

This commit is contained in:
Kovid Goyal
2025-11-12 09:31:31 +05:30
parent a9e71e5b5b
commit a4a7f77ef1
2 changed files with 4 additions and 2 deletions

View File

@@ -453,8 +453,9 @@ GLFWAPI GLFWColorScheme glfwGetCurrentSystemColorTheme(bool query_if_unintialize
if ([keyPath isEqualToString:@"effectiveAppearance"]) { if ([keyPath isEqualToString:@"effectiveAppearance"]) {
// The initial call (from NSKeyValueObservingOptionInitial) might happen on a background thread. // The initial call (from NSKeyValueObservingOptionInitial) might happen on a background thread.
// Dispatch to the main thread to be safe, especially if updating UI. // Dispatch to the main thread to be safe, especially if updating UI.
__block __typeof__(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self handleAppearanceChange]; [weakSelf handleAppearanceChange];
}); });
} }
} else { } else {

View File

@@ -2330,8 +2330,9 @@ void _glfwPlatformShowWindow(_GLFWwindow* window, bool move_to_active_screen)
NSWindowCollectionBehavior old = nw.collectionBehavior; NSWindowCollectionBehavior old = nw.collectionBehavior;
nw.collectionBehavior = (old & !NSWindowCollectionBehaviorCanJoinAllSpaces) | NSWindowCollectionBehaviorMoveToActiveSpace; nw.collectionBehavior = (old & !NSWindowCollectionBehaviorCanJoinAllSpaces) | NSWindowCollectionBehaviorMoveToActiveSpace;
[nw orderFront:nil]; [nw orderFront:nil];
__block __typeof__(nw) weakSelf = nw;
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
nw.collectionBehavior = old; weakSelf.collectionBehavior = old;
}); });
} }
} }