Made Application.Draw() thread-safe (for real this time). Fixes #136

This commit is contained in:
Oliver 2018-07-27 16:30:50 +02:00
parent 100f053ee1
commit cc64ead1ed
1 changed files with 3 additions and 2 deletions

View File

@ -227,13 +227,14 @@ func (a *Application) Suspend(f func()) bool {
// Draw refreshes the screen. It calls the Draw() function of the application's
// root primitive and then syncs the screen buffer.
func (a *Application) Draw() *Application {
a.RLock()
a.Lock()
defer a.Unlock()
screen := a.screen
root := a.root
fullscreen := a.rootFullscreen
before := a.beforeDraw
after := a.afterDraw
a.RUnlock()
// Maybe we're not ready yet or not anymore.
if screen == nil || root == nil {