From 573db3ced4c604f1f5971b39b1c95e0157b36e80 Mon Sep 17 00:00:00 2001 From: Rafael Lukas Maers Date: Fri, 25 Sep 2020 15:55:58 +0200 Subject: [PATCH] Lock until replacement is initialized This fixes a race condition in which the Application.draw is called from the event loop before the replacement screen is fully initialized in the screen event goroutine. This is also how it works in Application.Run. --- application.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application.go b/application.go index cd504d6..056c1d9 100644 --- a/application.go +++ b/application.go @@ -282,12 +282,12 @@ func (a *Application) Run() error { // We have a new screen. Keep going. a.Lock() a.screen = screen - a.Unlock() // Initialize and draw this screen. if err := screen.Init(); err != nil { panic(err) } + a.Unlock() a.draw() } }()