2
0
mirror of https://github.com/rivo/tview.git synced 2024-11-07 03:20:39 +00:00

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

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