From bc481ea784339e57b5f1bd6e67245597dd32765a Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 21 May 2019 15:56:56 +0200 Subject: [PATCH] ui/app: serialize event handling The frame callback for macOS comes in from a different thread than the UI thread. Serialize event handling to maintain the invariant that only one event is processed at a time. Signed-off-by: Elias Naur --- ui/app/window.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/app/window.go b/ui/app/window.go index 3415d952..71533ee3 100644 --- a/ui/app/window.go +++ b/ui/app/window.go @@ -35,6 +35,8 @@ type Window struct { events chan Event + eventLock sync.Mutex + mu sync.Mutex stage Stage size image.Point @@ -230,6 +232,8 @@ func (w *Window) contextDriver() interface{} { } func (w *Window) event(e Event) { + w.eventLock.Lock() + defer w.eventLock.Unlock() w.mu.Lock() needAck := false needRedraw := false