From 250b5ca0a65524b0261e165c3ae3efd02ab0b107 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 4 Jan 2020 18:07:34 +0100 Subject: [PATCH] Remove pixmap cache and pending art when removing parent nodes instead --- src/library/librarymodel.cpp | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/library/librarymodel.cpp b/src/library/librarymodel.cpp index 3c4e3121c..83d524d57 100644 --- a/src/library/librarymodel.cpp +++ b/src/library/librarymodel.cpp @@ -403,26 +403,7 @@ void LibraryModel::SongsDeleted(const SongList& songs) { if (node->parent != root_) parents << node->parent; - QModelIndex idx = ItemToIndex(node->parent); - - // Remove from pixmap cache - const QString cache_key = AlbumIconPixmapCacheKey(idx); - QPixmapCache::remove(cache_key); - icon_cache_->remove(QUrl(cache_key)); - if (pending_cache_keys_.contains(cache_key)) - pending_cache_keys_.remove(cache_key); - - // Remove from pending art loading - QMapIterator i(pending_art_); - while (i.hasNext()) { - i.next(); - if (i.value().first == node) { - pending_art_.remove(i.key()); - break; - } - } - - beginRemoveRows(idx, node->row, node->row); + beginRemoveRows(ItemToIndex(node->parent), node->row, node->row); node->parent->Delete(node->row); song_nodes_.remove(song.id()); endRemoveRows(); @@ -461,6 +442,25 @@ void LibraryModel::SongsDeleted(const SongList& songs) { else container_nodes_[node->container_level].remove(node->key); + // Remove from pixmap cache + const QString cache_key = AlbumIconPixmapCacheKey(ItemToIndex(node)); + QPixmapCache::remove(cache_key); + icon_cache_->remove(QUrl(cache_key)); + if (pending_cache_keys_.contains(cache_key)) { + pending_cache_keys_.remove(cache_key); + } + + // Remove from pending art loading + QMap::iterator i = pending_art_.begin(); + while (i != pending_art_.end()) { + if (i.value().first == node) { + i = pending_art_.erase(i); + } + else { + ++i; + } + } + // It was empty - delete it beginRemoveRows(ItemToIndex(node->parent), node->row, node->row); node->parent->Delete(node->row);