From cc64ead1ed59123faf6d6f37ae2aa1a51e4af4fe Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Fri, 27 Jul 2018 16:30:50 +0200 Subject: [PATCH] Made Application.Draw() thread-safe (for real this time). Fixes #136 --- application.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application.go b/application.go index f893578..bd4c5ac 100644 --- a/application.go +++ b/application.go @@ -227,13 +227,14 @@ func (a *Application) Suspend(f func()) bool { // Draw refreshes the screen. It calls the Draw() function of the application's // root primitive and then syncs the screen buffer. func (a *Application) Draw() *Application { - a.RLock() + a.Lock() + defer a.Unlock() + screen := a.screen root := a.root fullscreen := a.rootFullscreen before := a.beforeDraw after := a.afterDraw - a.RUnlock() // Maybe we're not ready yet or not anymore. if screen == nil || root == nil {