Remove album from pixmap cache when song is removed from library model

This commit is contained in:
Jonas Kvinge 2019-11-12 19:08:42 +01:00
parent 83c4c91a2e
commit 04baa9ec0f
1 changed files with 22 additions and 1 deletions

View File

@ -403,7 +403,25 @@ void LibraryModel::SongsDeleted(const SongList& songs) {
if (node->parent != root_) parents << node->parent;
beginRemoveRows(ItemToIndex(node->parent), node->row, node->row);
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<quint64, ItemAndCacheKey> 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);
node->parent->Delete(node->row);
song_nodes_.remove(song.id());
endRemoveRows();
@ -783,6 +801,9 @@ void LibraryModel::BeginReset() {
container_nodes_[2].clear();
divider_nodes_.clear();
pending_art_.clear();
pending_cache_keys_.clear();
QPixmapCache::clear();
icon_cache_->clear();
smart_playlist_node_ = nullptr;
root_ = new LibraryItem(this);