From 76386ad7adaf540d6aff8fec4e7956d7ab66b094 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Wed, 26 Apr 2023 08:38:56 -0700 Subject: [PATCH 1/2] fix potential crash in searching albums --- backend/albumiterator.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/albumiterator.go b/backend/albumiterator.go index b2ef1a1..d1d7cfa 100644 --- a/backend/albumiterator.go +++ b/backend/albumiterator.go @@ -185,20 +185,25 @@ func (s *searchIter) Next() *subsonic.AlbumID3 { // add results from artists search for _, artist := range results.Artist { artist, err := s.s.GetArtist(artist.ID) - if err != nil { + if err != nil || artist == nil { log.Printf("error fetching artist: %s", err.Error()) + } else { + s.addNewAlbums(artist.Album) } - s.addNewAlbums(artist.Album) } s.artistOffset += len(results.Artist) // add results from songs search for _, song := range results.Song { - album, err := s.s.GetAlbum(song.Parent) - if err != nil { - log.Printf("error fetching album: %s", err.Error()) + if song.AlbumID == "" { + continue + } + album, err := s.s.GetAlbum(song.AlbumID) + if err != nil || album == nil { + log.Printf("error fetching album: %s", err.Error()) + } else { + s.addNewAlbums([]*subsonic.AlbumID3{album}) } - s.addNewAlbums([]*subsonic.AlbumID3{album}) } s.songOffset += len(results.Song) } From d690c907c2b4ba5d04b313cacf18bad6954bc5d6 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Wed, 26 Apr 2023 17:21:26 -0700 Subject: [PATCH 2/2] Fix #149: correct MinSize calculation for CustomHyperlink --- ui/widgets/customhyperlink.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ui/widgets/customhyperlink.go b/ui/widgets/customhyperlink.go index 0380871..d85229f 100644 --- a/ui/widgets/customhyperlink.go +++ b/ui/widgets/customhyperlink.go @@ -58,9 +58,9 @@ type CustomHyperlink struct { NoTruncate bool Disabled bool - lastDisabled bool - container *fyne.Container - minSize fyne.Size + lastDisabled bool + container *fyne.Container + fullTextWidth float32 } func NewCustomHyperlink() *CustomHyperlink { @@ -74,8 +74,8 @@ func NewCustomHyperlink() *CustomHyperlink { c.OnTapped() } } + c.fullTextWidth = c.l.MinSize().Width c.ExtendBaseWidget(c) - c.minSize = c.h.MinSize() c.updateContainer(c.Disabled) return c } @@ -84,13 +84,8 @@ func (c *CustomHyperlink) SetText(text string) { c.l.Text = text lastWrapping := c.l.Wrapping c.l.Wrapping = fyne.TextWrapOff - s := c.l.MinSize() + c.fullTextWidth = c.l.MinSize().Width c.h.SetText(text) - if c.NoTruncate { - c.minSize = s - } else { - c.minSize = fyne.NewSize(fyne.Min(c.Size().Width, s.Width), s.Height) - } c.l.Wrapping = lastWrapping c.Refresh() } @@ -114,7 +109,10 @@ func (c *CustomHyperlink) Refresh() { } func (c *CustomHyperlink) MinSize() fyne.Size { - return c.minSize + if c.NoTruncate { + return fyne.NewSize(c.fullTextWidth, c.l.MinSize().Height) + } + return fyne.NewSize(0, c.l.MinSize().Height) } func (c *CustomHyperlink) CreateRenderer() fyne.WidgetRenderer {