Application does not lock on PollEvent() call anymore. Should resolve gridlocks when calling SetRoot() in goroutines. Resolves #6

This commit is contained in:
Oliver 2018-01-11 11:52:27 +01:00
parent fee6bd1ef9
commit 17c785e1f8
1 changed files with 6 additions and 3 deletions

View File

@ -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()