From d16a26605e90be27f86b9226e35cc0f77d17cba5 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 6 Aug 2020 21:40:42 +0200 Subject: [PATCH] Fix updating playlist songs when there are multiple files with the same URL Fixes #501 --- src/playlist/playlist.cpp | 9 +++------ src/playlist/playlist.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 412c5dada..5d2649ce1 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -1022,7 +1022,7 @@ void Playlist::InsertInternetItems(InternetService *service, const SongList &son } -void Playlist::UpdateItems(const SongList &songs) { +void Playlist::UpdateItems(SongList songs) { qLog(Debug) << "Updating playlist with new tracks' info"; @@ -1032,16 +1032,13 @@ void Playlist::UpdateItems(const SongList &songs) { // then we remove song from our list because we will not need to check it again. // And we also update undo actions. - QList songs_list; - for (const Song &song : songs) songs_list.append(song); - for (int i = 0; i < items_.size() ; i++) { // Update current items list - QMutableListIterator it(songs_list); + QMutableListIterator it(songs); while (it.hasNext()) { const Song &song = it.next(); const PlaylistItemPtr &item = items_[i]; - if (item->Metadata().url() == song.url()) { + if (item->Metadata().url() == song.url() && (item->Metadata().filetype() == Song::FileType_Unknown || item->Metadata().filetype() == Song::FileType_Stream || item->Metadata().filetype() == Song::FileType_CDDA)) { PlaylistItemPtr new_item; if (song.is_collection_song()) { new_item = PlaylistItemPtr(new CollectionPlaylistItem(song)); diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index c5ef6d186..81291029a 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -288,7 +288,7 @@ class Playlist : public QAbstractListModel { void ClearStreamMetadata(); void SetStreamMetadata(const QUrl &url, const Song &song, const bool minor); void ItemChanged(PlaylistItemPtr item); - void UpdateItems(const SongList &songs); + void UpdateItems(SongList songs); void Clear(); void RemoveDuplicateSongs();