From 8fc92ef345a2b0c1db7f56e65b1ff22556d22eeb Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 23 Dec 2012 12:02:56 +0100 Subject: [PATCH] * PixmapDelegateFader must not create rounded images before cache verification, since it creates a new QPixmap. --- src/libtomahawk/utils/PixmapDelegateFader.cpp | 23 +++++++++---------- src/libtomahawk/utils/PixmapDelegateFader.h | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/libtomahawk/utils/PixmapDelegateFader.cpp b/src/libtomahawk/utils/PixmapDelegateFader.cpp index be1c1979b..0461ceae6 100644 --- a/src/libtomahawk/utils/PixmapDelegateFader.cpp +++ b/src/libtomahawk/utils/PixmapDelegateFader.cpp @@ -19,14 +19,16 @@ */ #include "PixmapDelegateFader.h" -#include "TomahawkUtilsGui.h" -#include "Source.h" #include #include #include #include +#include "Source.h" +#include "TomahawkUtilsGui.h" +#include "Logger.h" + using namespace Tomahawk; QWeakPointer< TomahawkUtils::SharedTimeLine > PixmapDelegateFader::s_stlInstance = QWeakPointer< TomahawkUtils::SharedTimeLine >(); @@ -161,7 +163,7 @@ PixmapDelegateFader::albumChanged() if ( m_album.isNull() ) return; - QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, TomahawkUtils::createRoundedImage( m_album->cover( m_size ), QSize( 0, 0 ), m_mode == TomahawkUtils::Grid ? 0.00 : 0.20 ) ) ); + QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, m_album->cover( m_size ) ) ); } @@ -171,7 +173,7 @@ PixmapDelegateFader::artistChanged() if ( m_artist.isNull() ) return; - QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, TomahawkUtils::createRoundedImage( m_artist->cover( m_size ), QSize( 0, 0 ), m_mode == TomahawkUtils::Grid ? 0.00 : 0.20 ) ) ); + QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, m_artist->cover( m_size ) ) ); } @@ -181,8 +183,9 @@ PixmapDelegateFader::trackChanged() if ( m_track.isNull() ) return; - connect( m_track->displayQuery().data(), SIGNAL( coverChanged() ), SLOT( trackChanged() ) ); - QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, TomahawkUtils::createRoundedImage( m_track->displayQuery()->cover( m_size ), QSize( 0, 0 ), m_mode == TomahawkUtils::Grid ? 0.00 : 0.20 ) ) ); + connect( m_track->displayQuery().data(), SIGNAL( updated() ), SLOT( trackChanged() ), Qt::UniqueConnection ); + connect( m_track->displayQuery().data(), SIGNAL( coverChanged() ), SLOT( trackChanged() ), Qt::UniqueConnection ); + QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, m_track->displayQuery()->cover( m_size ) ) ); } @@ -193,14 +196,10 @@ PixmapDelegateFader::setPixmap( const QPixmap& pixmap ) return; m_defaultImage = false; - QCryptographicHash hash( QCryptographicHash::Md5 ); - const QImage img = pixmap.toImage(); - hash.addData( (const char*)img.constBits(), img.byteCount() ); - const QString newImageMd5 = hash.result(); + const qint64 newImageMd5 = pixmap.cacheKey(); if ( m_oldImageMd5 == newImageMd5 ) return; - m_oldImageMd5 = newImageMd5; if ( m_connectedToStl ) @@ -210,7 +209,7 @@ PixmapDelegateFader::setPixmap( const QPixmap& pixmap ) } m_oldReference = m_currentReference; - m_currentReference = pixmap; + m_currentReference = TomahawkUtils::createRoundedImage( pixmap, QSize( 0, 0 ), m_mode == TomahawkUtils::Grid ? 0.00 : 0.20 ); stlInstance().data()->setUpdateInterval( 20 ); m_startFrame = stlInstance().data()->currentFrame(); diff --git a/src/libtomahawk/utils/PixmapDelegateFader.h b/src/libtomahawk/utils/PixmapDelegateFader.h index f79c58774..04df7db1b 100644 --- a/src/libtomahawk/utils/PixmapDelegateFader.h +++ b/src/libtomahawk/utils/PixmapDelegateFader.h @@ -81,7 +81,7 @@ private: int m_startFrame; bool m_connectedToStl; float m_fadePct; - QString m_oldImageMd5; + qint64 m_oldImageMd5; bool m_defaultImage; QQueue m_pixmapQueue;