diff --git a/ui/browsing/albumpage.go b/ui/browsing/albumpage.go index ac2a539..9dd2944 100644 --- a/ui/browsing/albumpage.go +++ b/ui/browsing/albumpage.go @@ -189,6 +189,8 @@ type AlbumPageHeader struct { } func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader { + // due to widget reuse a.page can change so page MUST NOT + // be directly captured in a closure throughout this function! a := &AlbumPageHeader{page: page} a.ExtendBaseWidget(a) a.cover = widgets.NewTappableImage(func(*fyne.PointEvent) { go a.showPopUpCover() }) @@ -202,19 +204,19 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader { } a.artistLabel = widgets.NewCustomHyperlink() a.artistLabel.OnTapped = func() { - page.contr.NavigateTo(controller.ArtistRoute(a.artistID)) + a.page.contr.NavigateTo(controller.ArtistRoute(a.artistID)) } a.genreLabel = widgets.NewCustomHyperlink() a.genreLabel.OnTapped = func() { - page.contr.NavigateTo(controller.GenreRoute(a.genre)) + a.page.contr.NavigateTo(controller.GenreRoute(a.genre)) } a.miscLabel = widget.NewLabel("") playButton := widget.NewButtonWithIcon("Play", theme.MediaPlayIcon(), func() { - go page.pm.PlayAlbum(page.albumID, 0, false) + go a.page.pm.PlayAlbum(a.page.albumID, 0, false) }) shuffleBtn := widget.NewButtonWithIcon(" Shuffle", myTheme.ShuffleIcon, func() { - page.pm.LoadTracks(page.tracklist.GetTracks(), false, true) - page.pm.PlayFromBeginning() + a.page.pm.LoadTracks(a.page.tracklist.GetTracks(), false, true) + a.page.pm.PlayFromBeginning() }) var pop *widget.PopUpMenu menuBtn := widget.NewButtonWithIcon("", theme.MoreHorizontalIcon(), nil) diff --git a/ui/browsing/artistpage.go b/ui/browsing/artistpage.go index 1ec1789..05bf1ed 100644 --- a/ui/browsing/artistpage.go +++ b/ui/browsing/artistpage.go @@ -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() diff --git a/ui/browsing/playlistpage.go b/ui/browsing/playlistpage.go index d28bd5a..f18a9a5 100644 --- a/ui/browsing/playlistpage.go +++ b/ui/browsing/playlistpage.go @@ -246,6 +246,8 @@ type PlaylistPageHeader struct { } func NewPlaylistPageHeader(page *PlaylistPage) *PlaylistPageHeader { + // due to widget reuse a.page can change so page MUST NOT + // be directly captured in a closure throughout this function! a := &PlaylistPageHeader{page: page} a.ExtendBaseWidget(a) @@ -261,18 +263,18 @@ func NewPlaylistPageHeader(page *PlaylistPage) *PlaylistPageHeader { a.trackTimeLabel = widget.NewLabel("") a.editButton = widget.NewButtonWithIcon("Edit", theme.DocumentCreateIcon(), func() { if a.playlistInfo != nil { - page.contr.DoEditPlaylistWorkflow(&a.playlistInfo.Playlist) + a.page.contr.DoEditPlaylistWorkflow(&a.playlistInfo.Playlist) } }) a.editButton.Hidden = true playButton := widget.NewButtonWithIcon("Play", theme.MediaPlayIcon(), func() { - page.pm.LoadTracks(page.tracks, false, false) - page.pm.PlayFromBeginning() + a.page.pm.LoadTracks(a.page.tracks, false, false) + a.page.pm.PlayFromBeginning() }) // TODO: find way to pad shuffle svg rather than using a space in the label string shuffleBtn := widget.NewButtonWithIcon(" Shuffle", myTheme.ShuffleIcon, func() { - page.pm.LoadTracks(page.tracks, false /*append*/, true /*shuffle*/) - page.pm.PlayFromBeginning() + a.page.pm.LoadTracks(a.page.tracks, false /*append*/, true /*shuffle*/) + a.page.pm.PlayFromBeginning() }) var pop *widget.PopUpMenu menuBtn := widget.NewButtonWithIcon("", theme.MoreHorizontalIcon(), nil)