From 17c785e1f8aee169fe6c3fe9eb7dbbcc9843999e Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Thu, 11 Jan 2018 11:52:27 +0100 Subject: [PATCH] Application does not lock on PollEvent() call anymore. Should resolve gridlocks when calling SetRoot() in goroutines. Resolves #6 --- application.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/application.go b/application.go index cdf01bf..3b66e00 100644 --- a/application.go +++ b/application.go @@ -112,15 +112,18 @@ func (a *Application) Run() error { // Start event loop. for { a.RLock() - if a.screen == nil { - a.RUnlock() + screen := a.screen + a.RUnlock() + if screen == nil { break } + + // Wait for next event. event := a.screen.PollEvent() - a.RUnlock() if event == nil { break // The screen was finalized. } + switch event := event.(type) { case *tcell.EventKey: a.RLock()