Skip to content

Commit

Permalink
add locking in RefreshItem
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Nov 18, 2023
1 parent 913e656 commit 98d80b1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions widget/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 98d80b1

Please sign in to comment.