shithub: drawterm

Download patch

ref: c039c904fa199fc049864295726a61a6fe191998
parent: 49142f5becabaccddde13dbb00f85f998778a2a4
author: mia soweli <inbox@tachibana-labs.org>
date: Thu Jul 13 13:01:10 EDT 2023

gui-*: more drawlock fixes

terminit() should run with draw lock held.

--- a/gui-android/cpp/android.c
+++ b/gui-android/cpp/android.c
@@ -174,8 +174,8 @@
 	if (gscreen == nil)
 		panic("screensize failed");
 	gscreen->clipr = r;
-	terminit();
 	qlock(&drawlock);
+	terminit();
 	flushmemscreen(r);
 	qunlock(&drawlock);
 	return;
--- a/gui-cocoa/screen.m
+++ b/gui-cocoa/screen.m
@@ -68,7 +68,9 @@
 	memimageinit();
 	screensize(Rect(0, 0, winsize.width, winsize.height), ABGR32);
 	gscreen->clipr = Rect(0, 0, winsize.width, winsize.height);
+	qlock(&drawlock);
 	terminit();
+	qunlock(&drawlock);
 }
 
 void
--- a/gui-fbdev/fbdev.c
+++ b/gui-fbdev/fbdev.c
@@ -388,9 +388,8 @@
 	gscreen->clipr = screenr;
 	kproc("fbdev", fbproc, nil);
 
-	terminit();
-
 	qlock(&drawlock);
+	terminit();
 	flushmemscreen(gscreen->clipr);
 	qunlock(&drawlock);
 }
--- a/gui-osx/screen.c
+++ b/gui-osx/screen.c
@@ -211,7 +211,9 @@
 	ShowMenuBar();
 	window_resized();
 	SelectWindow(theWindow);
+	qlock(&drawlock);
 	terminit();
+	qunlock(&drawlock);
 	// Run the event loop
 	readybit = 1;
 	wakeup(&rend);
--- a/gui-x11/x11.c
+++ b/gui-x11/x11.c
@@ -375,9 +375,8 @@
 	gscreen->clipr = r;
 	kproc("xscreen", xproc, nil);
 
-	terminit();
-
 	qlock(&drawlock);
+	terminit();
 	flushmemscreen(gscreen->clipr);
 	qunlock(&drawlock);
 }