mirror of
https://github.com/rivo/tview.git
synced 2025-04-28 13:48:53 +08:00
Made Application.Draw() thread-safe (for real this time). Fixes #136
This commit is contained in:
parent
100f053ee1
commit
cc64ead1ed
@ -227,13 +227,14 @@ func (a *Application) Suspend(f func()) bool {
|
|||||||
// Draw refreshes the screen. It calls the Draw() function of the application's
|
// Draw refreshes the screen. It calls the Draw() function of the application's
|
||||||
// root primitive and then syncs the screen buffer.
|
// root primitive and then syncs the screen buffer.
|
||||||
func (a *Application) Draw() *Application {
|
func (a *Application) Draw() *Application {
|
||||||
a.RLock()
|
a.Lock()
|
||||||
|
defer a.Unlock()
|
||||||
|
|
||||||
screen := a.screen
|
screen := a.screen
|
||||||
root := a.root
|
root := a.root
|
||||||
fullscreen := a.rootFullscreen
|
fullscreen := a.rootFullscreen
|
||||||
before := a.beforeDraw
|
before := a.beforeDraw
|
||||||
after := a.afterDraw
|
after := a.afterDraw
|
||||||
a.RUnlock()
|
|
||||||
|
|
||||||
// Maybe we're not ready yet or not anymore.
|
// Maybe we're not ready yet or not anymore.
|
||||||
if screen == nil || root == nil {
|
if screen == nil || root == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user