From 98d80b1b0cfaf7505b225fb51e226fe929aab80a Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sat, 18 Nov 2023 10:18:16 -0800 Subject: [PATCH] add locking in RefreshItem --- widget/list.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/widget/list.go b/widget/list.go index f4660ee6c9..7e11fed705 100644 --- a/widget/list.go +++ b/widget/list.go @@ -123,7 +123,10 @@ func (l *List) RefreshItem(id ListItemID) { } l.BaseWidget.Refresh() lo := l.scroller.Content.(*fyne.Container).Layout.(*listLayout) - if item, ok := lo.searchVisible(lo.visible, id); ok { + lo.renderLock.RLock() // ensures we are not changing visible info in render code during the search + item, ok := lo.searchVisible(lo.visible, id) + lo.renderLock.RUnlock() + if ok { lo.setupListItem(item, id, l.focused && l.currentFocus == id) } } @@ -537,7 +540,7 @@ type listLayout struct { visible []itemAndID wasVisible []itemAndID visibleRowHeights []float32 - renderLock sync.Mutex + renderLock sync.RWMutex } func newListLayout(list *List) fyne.Layout {