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
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 2 deletions

View file

@ -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 {

View file

@ -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;
});
}
}