mirror of
https://github.com/rivo/tview.git
synced 2024-11-15 06:12:46 +00:00
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.
This commit is contained in:
parent
53d50e499b
commit
573db3ced4
@ -282,12 +282,12 @@ func (a *Application) Run() error {
|
|||||||
// We have a new screen. Keep going.
|
// We have a new screen. Keep going.
|
||||||
a.Lock()
|
a.Lock()
|
||||||
a.screen = screen
|
a.screen = screen
|
||||||
a.Unlock()
|
|
||||||
|
|
||||||
// Initialize and draw this screen.
|
// Initialize and draw this screen.
|
||||||
if err := screen.Init(); err != nil {
|
if err := screen.Init(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
a.Unlock()
|
||||||
a.draw()
|
a.draw()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user