Calling ForceDraw from a goroutine can cause a panic
```
panic: runtime error: index out of range [19] with length 1
goroutine 39 [running]:
github.com/rivo/tview.(*TreeView).Draw(0x140000b0320, {0x102f01ee8, 0x1400008e4b0})
/home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20241103174730-c76f7879f592/treeview.go:762 +0x7ec
github.com/rivo/tview.(*Flex).Draw(0x140002220f0, {0x102f01ee8, 0x1400008e4b0})
/home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20241103174730-c76f7879f592/flex.go:200 +0x2a8
github.com/rivo/tview.(*Flex).Draw(0x140002221e0, {0x102f01ee8, 0x1400008e4b0})
/home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20241103174730-c76f7879f592/flex.go:200 +0x2a8
github.com/rivo/tview.(*Flex).Draw(0x14000222240, {0x102f01ee8, 0x1400008e4b0})
/home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20241103174730-c76f7879f592/flex.go:200 +0x2a8
github.com/rivo/tview.(*Flex).Draw(0x14000222270, {0x102f01ee8, 0x1400008e4b0})
/home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20241103174730-c76f7879f592/flex.go:204 +0x2ec
github.com/rivo/tview.(*Pages).Draw(0x14000099770, {0x102f01ee8, 0x1400008e4b0})
/home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20241103174730-c76f7879f592/pages.go:291 +0xdc
github.com/rivo/tview.(*Application).draw(0x14000240000)
/home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20241103174730-c76f7879f592/application.go:711 +0x10c
github.com/rivo/tview.(*Application).ForceDraw(...)
/home/runner/go/pkg/mod/github.com/rivo/tview@v0.0.0-20241103174730-c76f7879f592/application.go:674
github.com/jorgerojas26/lazysql/components.(*ResultsTable).SetLoading(0x14000282000, 0xec?)
/home/runner/work/lazysql/lazysql/components/results_table.go:934 +0xcc
github.com/jorgerojas26/lazysql/components.(*ResultsTable).FetchRecords(0x14000282000, 0x1400008f910)
/home/runner/work/lazysql/lazysql/components/results_table.go:1005 +0x5c
github.com/jorgerojas26/lazysql/components.(*Home).showTable(0x1400089c000, {0x140000243a0, 0xb}, {0x140000243ac, 0x11})
/home/runner/work/lazysql/lazysql/components/home.go:215 +0x294
github.com/jorgerojas26/lazysql/components.(*Home).subscribeToTreeChanges(0x1400089c000)
/home/runner/work/lazysql/lazysql/components/home.go:137 +0x3c4
created by github.com/jorgerojas26/lazysql/components.NewHomePage in goroutine 50
/home/runner/work/lazysql/lazysql/components/home.go:90 +0x320
```
According to the [documentation](https://pkg.go.dev/github.com/rivo/tview#Application.ForceDraw), `ForceDraw` should not be called from a goroutine.
关闭于 2026-02-27 1 条评论