1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 16:29:43 +01:00

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
This commit is contained in:
Jeff Mitchell 2012-05-23 11:15:36 -04:00
parent 0fb1511904
commit 3159cfd840
3 changed files with 8 additions and 4 deletions

View File

@ -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 )

View File

@ -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;

View File

@ -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();
}