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

Alexandre Julliard julliard at winehq.org
Mon Apr 20 15:01:57 CDT 2020


Module: wine
Branch: oldstable
Commit: ed092ee074279ac3c41a5e7631a13a8639b28895
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ed092ee074279ac3c41a5e7631a13a8639b28895

Author: Ken Thomases <ken at codeweavers.com>
Date:   Wed Dec 11 11:49:47 2019 -0600

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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 1261589c2cc68061d4bd9d41a387cd4979d7073c)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/winemac.drv/cocoa_opengl.m | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_opengl.m b/dlls/winemac.drv/cocoa_opengl.m
index 5a097a12d2..e60b0b388b 100644
--- a/dlls/winemac.drv/cocoa_opengl.m
+++ b/dlls/winemac.drv/cocoa_opengl.m
@@ -79,8 +79,10 @@
             macdrv_set_view_backing_size((macdrv_view)self.view, view_backing);
 
             NSView* save = self.view;
-            [super clearDrawable];
-            [super setView:save];
+            OnMainThread(^{
+                [super clearDrawable];
+                [super setView:save];
+            });
             shouldClearToBlack = TRUE;
         }
     }
@@ -122,7 +124,11 @@
     - (void) setView:(NSView*)newView
     {
         NSView* oldView = [self view];
-        [super setView:newView];
+        if ([NSThread isMainThread])
+            [super setView:newView];
+        else OnMainThread(^{
+            [super setView:newView];
+        });
         [newView retain];
         [oldView release];
     }
@@ -130,7 +136,11 @@
     - (void) clearDrawable
     {
         NSView* oldView = [self view];
-        [super clearDrawable];
+        if ([NSThread isMainThread])
+            [super clearDrawable];
+        else OnMainThread(^{
+            [super clearDrawable];
+        });
         [oldView release];
 
         [self wine_updateBackingSize:NULL];




More information about the wine-cvs mailing list