Fix 3 calls to AppKit that were not being done from the main thread, found using Apple's [Main Thread Checker](https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and...).
I used it with Wine by dlopen()ing `/Applications/Xcode.app/Contents/Developer/usr/lib/libMainThreadChecker.dylib` in `macdrv_init()`, commenting out the `SIGABRT` handler in `signal_x86_64.c`, and setting `MTC_CRASH_ON_REPORT=1` so the process will `abort()` and eventually generate a crash log+backtrace.
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/cocoa_window.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index ce8b571fa23..4c15e211442 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -3618,7 +3618,9 @@ void macdrv_set_window_alpha(macdrv_window w, CGFloat alpha) { WineWindow* window = (WineWindow*)w;
- [window setAlphaValue:alpha]; + OnMainThread(^{ + [window setAlphaValue:alpha]; + }); } }
From: Brendan Shanks bshanks@codeweavers.com
--- dlls/winemac.drv/cocoa_opengl.m | 4 +++- dlls/winemac.drv/cocoa_window.m | 16 ++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_opengl.m b/dlls/winemac.drv/cocoa_opengl.m index 5e3ad03a8b2..6a88519e5db 100644 --- a/dlls/winemac.drv/cocoa_opengl.m +++ b/dlls/winemac.drv/cocoa_opengl.m @@ -51,6 +51,7 @@ - (void) dealloc + (NSView*) dummyView { static NSWindow* dummyWindow; + static NSView* dummyWindowContentView; static dispatch_once_t once;
dispatch_once(&once, ^{ @@ -59,10 +60,11 @@ + (NSView*) dummyView styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO]; + dummyWindowContentView = dummyWindow.contentView; }); });
- return dummyWindow.contentView; + return dummyWindowContentView; }
// Normally, we take care that disconnecting a context from a view doesn't diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 4c15e211442..7aa3dbf81c7 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -3783,16 +3783,16 @@ void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, ma { @autoreleasepool { - WineContentView* view = (WineContentView*)v; - WineContentView* superview = (WineContentView*)s; - WineWindow* window = (WineWindow*)w; - WineContentView* prev = (WineContentView*)p; - WineContentView* next = (WineContentView*)n; + OnMainThreadAsync(^{ + WineContentView* view = (WineContentView*)v; + WineContentView* superview = (WineContentView*)s; + WineWindow* window = (WineWindow*)w; + WineContentView* prev = (WineContentView*)p; + WineContentView* next = (WineContentView*)n;
- if (!superview) - superview = [window contentView]; + if (!superview) + superview = [window contentView];
- OnMainThreadAsync(^{ if (superview == [view superview]) { NSArray* subviews = [superview subviews];
This merge request was approved by Tim Clem.