diff --git a/src/libtomahawk/Album.cpp b/src/libtomahawk/Album.cpp index 66297c699..8100c3fbe 100644 --- a/src/libtomahawk/Album.cpp +++ b/src/libtomahawk/Album.cpp @@ -31,6 +31,7 @@ #include "utils/Logger.h" #include +#include using namespace Tomahawk; @@ -282,15 +283,16 @@ Album::cover( const QSize& size, bool forceLoad ) const if ( m_cover && !m_cover->isNull() && !size.isEmpty() ) { - if ( m_coverCache.contains( size.width() ) ) - { - return m_coverCache.value( size.width() ); - } + const QString cacheKey = infoid() + "_" + size.width(); + QPixmap cover; - QPixmap scaledCover; - scaledCover = m_cover->scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - m_coverCache.insert( size.width(), scaledCover ); - return scaledCover; + if ( !QPixmapCache::find( cacheKey, cover ) ) + { + cover = m_cover->scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); + QPixmapCache::insert( cacheKey, cover ); + return cover; + } + return cover; } if ( m_cover ) diff --git a/src/libtomahawk/Album.h b/src/libtomahawk/Album.h index edbb48f4f..a137f6b9f 100644 --- a/src/libtomahawk/Album.h +++ b/src/libtomahawk/Album.h @@ -102,7 +102,6 @@ private: mutable QByteArray m_coverBuffer; #ifndef ENABLE_HEADLESS mutable QPixmap* m_cover; - mutable QHash< int, QPixmap > m_coverCache; #endif QHash< Tomahawk::ModelMode, QHash< Tomahawk::collection_ptr, Tomahawk::playlistinterface_ptr > > m_playlistInterface; diff --git a/src/libtomahawk/Artist.cpp b/src/libtomahawk/Artist.cpp index b7998c32c..4f61307f7 100644 --- a/src/libtomahawk/Artist.cpp +++ b/src/libtomahawk/Artist.cpp @@ -33,6 +33,7 @@ #include "utils/Logger.h" #include +#include using namespace Tomahawk; @@ -585,15 +586,16 @@ Artist::cover( const QSize& size, bool forceLoad ) const if ( m_cover && !m_cover->isNull() && !size.isEmpty() ) { - if ( m_coverCache.contains( size.width() ) ) - { - return m_coverCache.value( size.width() ); - } + const QString cacheKey = infoid() + "_" + size.width(); + QPixmap cover; - QPixmap scaledCover; - scaledCover = m_cover->scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); - m_coverCache.insert( size.width(), scaledCover ); - return scaledCover; + if ( !QPixmapCache::find( cacheKey, cover ) ) + { + cover = m_cover->scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); + QPixmapCache::insert( cacheKey, cover ); + return cover; + } + return cover; } if ( m_cover ) diff --git a/src/libtomahawk/Artist.h b/src/libtomahawk/Artist.h index e80d54c42..88ed10b37 100644 --- a/src/libtomahawk/Artist.h +++ b/src/libtomahawk/Artist.h @@ -131,7 +131,6 @@ private: mutable QByteArray m_coverBuffer; #ifndef ENABLE_HEADLESS mutable QPixmap* m_cover; - mutable QHash< int, QPixmap > m_coverCache; #endif QHash< Tomahawk::ModelMode, QHash< Tomahawk::collection_ptr, Tomahawk::playlistinterface_ptr > > m_playlistInterface;