1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Fix race with HighlightableHelper

GetRect can lead to a race condition
Add a RenderFunc method so that we can call try to
wrap even more of our rendering in the thread safe
`QueueUpdateDraw` method
This commit is contained in:
Sean Smith
2019-08-24 22:05:37 -04:00
parent 3f5fe6f3e5
commit 264f49fd2c
12 changed files with 69 additions and 45 deletions

View File

@@ -9,7 +9,8 @@ import (
"github.com/wtfutil/wtf/utils"
)
func (widget *Widget) contentFrom(data []*transmissionrpc.Torrent) string {
func (widget *Widget) content() (string, string, bool) {
data := widget.torrents
str := ""
for idx, torrent := range data {
@@ -27,12 +28,11 @@ func (widget *Widget) contentFrom(data []*transmissionrpc.Torrent) string {
str += utils.HighlightableHelper(widget.View, row, idx, len(torrName))
}
return str
return widget.CommonSettings().Title, str, false
}
func (widget *Widget) display() {
content := widget.contentFrom(widget.torrents)
widget.ScrollableWidget.Redraw(widget.CommonSettings().Title, content, false)
widget.ScrollableWidget.RedrawFunc(widget.content)
}
func (widget *Widget) prettyTorrentName(name string) string {