Skip to content

Commit

Permalink
Make the accordion renderer grab the readlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Jan 29, 2024
1 parent 39e7c72 commit b54c81d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions widget/accordion.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ func (r *accordionRenderer) Layout(size fyne.Size) {
x := float32(0)
y := float32(0)
hasOpen := 0

r.container.propertyLock.RLock()
defer r.container.propertyLock.RUnlock()

for i, ai := range r.container.Items {
h := r.headers[i]
min := h.MinSize().Height
Expand Down Expand Up @@ -205,8 +209,13 @@ func (r *accordionRenderer) Layout(size fyne.Size) {
}
}

func (r *accordionRenderer) MinSize() (size fyne.Size) {
func (r *accordionRenderer) MinSize() fyne.Size {
pad := theme.Padding()
size := fyne.Size{}

r.container.propertyLock.RLock()
defer r.container.propertyLock.RUnlock()

for i, ai := range r.container.Items {
if i != 0 {
size.Height += pad
Expand All @@ -221,7 +230,8 @@ func (r *accordionRenderer) MinSize() (size fyne.Size) {
size.Height += pad
}
}
return

return size
}

func (r *accordionRenderer) Refresh() {
Expand All @@ -231,6 +241,9 @@ func (r *accordionRenderer) Refresh() {
}

func (r *accordionRenderer) updateObjects() {
r.container.propertyLock.RLock()
defer r.container.propertyLock.RUnlock()

is := len(r.container.Items)
hs := len(r.headers)
ds := len(r.dividers)
Expand Down

0 comments on commit b54c81d

Please sign in to comment.