From 3159cfd84029a1d505e09527cf85ccb198258eaa Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 23 May 2012 11:15:36 -0400 Subject: [PATCH] Make the Tomahawk cache spit out a more useful error when data not found, and stop Sources from endlessely querying it for avatars that we already know don't exist --- src/libtomahawk/Source.cpp | 7 +++++-- src/libtomahawk/Source.h | 3 ++- src/libtomahawk/utils/TomahawkCache.cpp | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libtomahawk/Source.cpp b/src/libtomahawk/Source.cpp index cd625a06b..232237054 100644 --- a/src/libtomahawk/Source.cpp +++ b/src/libtomahawk/Source.cpp @@ -48,6 +48,7 @@ Source::Source( int id, const QString& username ) , m_username( username ) , m_id( id ) , m_updateIndexWhenSynced( false ) + , m_avatarUpdated( true ) , m_state( DBSyncConnection::UNKNOWN ) , m_cc( 0 ) , m_commandCount( 0 ) @@ -136,13 +137,14 @@ Source::setAvatar( const QPixmap& avatar ) tDebug() << Q_FUNC_INFO << friendlyName() << m_username << ba.count(); TomahawkUtils::Cache::instance()->putData( "Sources", 7776000000 /* 90 days */, m_username, ba ); + m_avatarUpdated = true; } QPixmap -Source::avatar( AvatarStyle style, const QSize& size ) const +Source::avatar( AvatarStyle style, const QSize& size ) { - if ( !m_avatar ) + if ( !m_avatar && m_avatarUpdated ) { m_avatar = new QPixmap(); QByteArray ba = TomahawkUtils::Cache::instance()->getData( "Sources", m_username ).toByteArray(); @@ -154,6 +156,7 @@ Source::avatar( AvatarStyle style, const QSize& size ) const delete m_avatar; m_avatar = 0; } + m_avatarUpdated = false; } if ( style == FancyStyle && m_avatar && !m_fancyAvatar ) diff --git a/src/libtomahawk/Source.h b/src/libtomahawk/Source.h index cd45bbc83..883b605dc 100644 --- a/src/libtomahawk/Source.h +++ b/src/libtomahawk/Source.h @@ -66,7 +66,7 @@ public: #ifndef ENABLE_HEADLESS void setAvatar( const QPixmap& avatar ); - QPixmap avatar( AvatarStyle style = Original, const QSize& size = QSize() ) const; + QPixmap avatar( AvatarStyle style = Original, const QSize& size = QSize() ); #endif collection_ptr collection() const; @@ -147,6 +147,7 @@ private: int m_id; bool m_scrubFriendlyName; bool m_updateIndexWhenSynced; + bool m_avatarUpdated; Tomahawk::query_ptr m_currentTrack; QString m_textStatus; diff --git a/src/libtomahawk/utils/TomahawkCache.cpp b/src/libtomahawk/utils/TomahawkCache.cpp index e69baac16..51e58f313 100644 --- a/src/libtomahawk/utils/TomahawkCache.cpp +++ b/src/libtomahawk/utils/TomahawkCache.cpp @@ -101,7 +101,7 @@ QVariant Cache::getData ( const QString& identifier, const QString& key ) return data.data; } - tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "No such client" << identifier; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "No such key" << key; return QVariant(); }