winemac: Only manipulate an NSOpenGLContext's view on the main thread.

I was seeing a crash due to an assert about manipulating it on a
background thread. I can't recall where I was seeing that. I think it's
new in Catalina.

Signed-off-by: Chip Davis <cdavis@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ken Thomases 2019-12-11 11:49:47 -06:00 committed by Alexandre Julliard
parent c70c10564a
commit 1261589c2c
1 changed files with 14 additions and 4 deletions

View File

@ -79,8 +79,10 @@ - (void) resetSurfaceIfBackingSizeChanged
macdrv_set_view_backing_size((macdrv_view)self.view, view_backing); macdrv_set_view_backing_size((macdrv_view)self.view, view_backing);
NSView* save = self.view; NSView* save = self.view;
[super clearDrawable]; OnMainThread(^{
[super setView:save]; [super clearDrawable];
[super setView:save];
});
shouldClearToBlack = TRUE; shouldClearToBlack = TRUE;
} }
} }
@ -122,7 +124,11 @@ - (void) wine_updateBackingSize:(const CGSize*)size
- (void) setView:(NSView*)newView - (void) setView:(NSView*)newView
{ {
NSView* oldView = [self view]; NSView* oldView = [self view];
[super setView:newView]; if ([NSThread isMainThread])
[super setView:newView];
else OnMainThread(^{
[super setView:newView];
});
[newView retain]; [newView retain];
[oldView release]; [oldView release];
} }
@ -130,7 +136,11 @@ - (void) setView:(NSView*)newView
- (void) clearDrawable - (void) clearDrawable
{ {
NSView* oldView = [self view]; NSView* oldView = [self view];
[super clearDrawable]; if ([NSThread isMainThread])
[super clearDrawable];
else OnMainThread(^{
[super clearDrawable];
});
[oldView release]; [oldView release];
[self wine_updateBackingSize:NULL]; [self wine_updateBackingSize:NULL];