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

pull/7/merge
Oliver 7 years ago
parent fee6bd1ef9
commit 17c785e1f8

@ -112,15 +112,18 @@ func (a *Application) Run() error {
// Start event loop. // Start event loop.
for { for {
a.RLock() a.RLock()
if a.screen == nil { screen := a.screen
a.RUnlock() a.RUnlock()
if screen == nil {
break break
} }
// Wait for next event.
event := a.screen.PollEvent() event := a.screen.PollEvent()
a.RUnlock()
if event == nil { if event == nil {
break // The screen was finalized. break // The screen was finalized.
} }
switch event := event.(type) { switch event := event.(type) {
case *tcell.EventKey: case *tcell.EventKey:
a.RLock() a.RLock()

Loading…
Cancel
Save