1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-29 01:29:55 +01:00

Fix updating playlist songs when there are multiple files with the same URL

Fixes #501
This commit is contained in:
Jonas Kvinge 2020-08-06 21:40:42 +02:00
parent a4f692c788
commit d16a26605e
2 changed files with 4 additions and 7 deletions

View File

@ -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<Song> songs_list;
for (const Song &song : songs) songs_list.append(song);
for (int i = 0; i < items_.size() ; i++) {
// Update current items list
QMutableListIterator<Song> it(songs_list);
QMutableListIterator<Song> 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));

View File

@ -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();