From 67b25dea819ea27a9229afebee65e4110c4c6678 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 8 Aug 2023 18:41:56 +0200 Subject: fix broken indices in songs after Playlist.OrderedList() 04205039f24ea6e71d2ce94c7cb7e1395f95179e was not enough to fix the ordered list issue introduced by 26f0033ebb5f8e7c204a042709e3dfa885eac868. heap.Pop uses Swap internally which modifies as songs index. We fix the broken indices by overriding them after the ordered list was created. --- playlist.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'playlist.go') diff --git a/playlist.go b/playlist.go index 049354e..c11843e 100644 --- a/playlist.go +++ b/playlist.go @@ -72,6 +72,12 @@ func (pl *Playlist) OrderedList() []*Song { songs = append(songs, heap.Pop(&cpy).(*Song)) } + // TODO: Use more efficiently traversable data structure + llog.DDebug("fix song indices in pl") + for i, s := range *pl { + s.index = i + } + llog.DDebug("ordering queue %v returned %v", pl, songs) return songs } -- cgit v1.2.3