commit 26c6b2579543e928158fa7d3c00d8b0e04ac270c
parent dc60de7b64948e89832f03181e6db799060036b8
Author: Russ Cox <rsc@swtch.com>
Date: Fri, 5 Apr 2019 15:04:10 -0400
devdraw: avoid deadlock on pre-Mojave macOS
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m
@@ -541,6 +541,11 @@ _flushmemscreen(Rectangle r)
return;
rect = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r));
+
+ // This can get blocked behind responding to mouse events,
+ // which need to acquire the zlock, so let go of it during
+ // the flush. Perhaps the waitUntilDone:YES is wrong?
+ zunlock();
[appdelegate
performSelectorOnMainThread:@selector(callflushimg:)
withObject:[NSValue valueWithRect:rect]
@@ -548,6 +553,7 @@ _flushmemscreen(Rectangle r)
modes:[NSArray arrayWithObjects:
NSRunLoopCommonModes,
@"waiting image", nil]];
+ zlock();
}
static void drawimg(NSRect, uint);