Fixes #222: ensure pooled PageHeaders don't hold onto old state in closures

This commit is contained in:
Drew Weymouth
2023-07-17 17:07:13 -07:00
parent 5a5f551613
commit 5bb65ee6aa
3 changed files with 17 additions and 11 deletions
+3 -1
View File
@@ -287,6 +287,8 @@ type ArtistPageHeader struct {
}
func NewArtistPageHeader(page *ArtistPage) *ArtistPageHeader {
// due to widget reuse a.artistPage can change so page MUST NOT
// be directly captured in a closure throughout this function!
a := &ArtistPageHeader{
artistPage: page,
titleDisp: widget.NewRichTextWithText(""),
@@ -306,7 +308,7 @@ func NewArtistPageHeader(page *ArtistPage) *ArtistPageHeader {
a.playBtn = widget.NewButtonWithIcon("Play Discography", theme.MediaPlayIcon(), func() {
go a.artistPage.contr.PlayArtistDiscography(a.artistID, false /*shuffle*/)
})
a.playRadioBtn = widget.NewButtonWithIcon(" Play Artist Radio", myTheme.ShuffleIcon, page.playArtistRadio)
a.playRadioBtn = widget.NewButtonWithIcon(" Play Artist Radio", myTheme.ShuffleIcon, a.artistPage.playArtistRadio)
a.biographyDisp.Wrapping = fyne.TextWrapWord
a.ExtendBaseWidget(a)
a.createContainer()