From 2be9dfc45b62d7d8af70d4c0293c68f36d0de061 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 6 Apr 2012 14:55:03 -0400 Subject: [PATCH] Don't ask the infosystem for the same item data more than once racily --- src/libtomahawk/album.cpp | 5 ++++- src/libtomahawk/album.h | 1 + src/libtomahawk/artist.cpp | 5 ++++- src/libtomahawk/artist.h | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/album.cpp b/src/libtomahawk/album.cpp index 02e7a5c8e..7ca104c49 100644 --- a/src/libtomahawk/album.cpp +++ b/src/libtomahawk/album.cpp @@ -78,6 +78,7 @@ Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr& , m_name( name ) , m_artist( artist ) , m_infoLoaded( false ) + , m_infoLoading( false ) #ifndef ENABLE_HEADLESS , m_cover( 0 ) #endif @@ -107,7 +108,7 @@ Album::artist() const QPixmap Album::cover( const QSize& size, bool forceLoad ) const { - if ( !m_infoLoaded ) + if ( !m_infoLoaded && !m_infoLoading ) { if ( !forceLoad ) return QPixmap(); @@ -133,6 +134,8 @@ Album::cover( const QSize& size, bool forceLoad ) const SLOT( infoSystemFinished( QString ) ) ); Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData ); + + m_infoLoading = true; } if ( !m_cover && !m_coverBuffer.isEmpty() ) diff --git a/src/libtomahawk/album.h b/src/libtomahawk/album.h index 47f281c92..72b51fc07 100644 --- a/src/libtomahawk/album.h +++ b/src/libtomahawk/album.h @@ -76,6 +76,7 @@ private: artist_ptr m_artist; QByteArray m_coverBuffer; bool m_infoLoaded; + mutable bool m_infoLoading; mutable QString m_uuid; #ifndef ENABLE_HEADLESS diff --git a/src/libtomahawk/artist.cpp b/src/libtomahawk/artist.cpp index 4a019e624..e90da1a42 100644 --- a/src/libtomahawk/artist.cpp +++ b/src/libtomahawk/artist.cpp @@ -77,6 +77,7 @@ Artist::Artist( unsigned int id, const QString& name ) , m_id( id ) , m_name( name ) , m_infoLoaded( false ) + , m_infoLoading( false ) #ifndef ENABLE_HEADLESS , m_cover( 0 ) #endif @@ -99,7 +100,7 @@ Artist::onTracksAdded( const QList& tracks ) QPixmap Artist::cover( const QSize& size, bool forceLoad ) const { - if ( !m_infoLoaded ) + if ( !m_infoLoaded || !m_infoLoading ) { if ( !forceLoad ) return QPixmap(); @@ -123,6 +124,8 @@ Artist::cover( const QSize& size, bool forceLoad ) const SLOT( infoSystemFinished( QString ) ) ); Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData ); + + m_infoLoading = true; } if ( !m_cover && !m_coverBuffer.isEmpty() ) diff --git a/src/libtomahawk/artist.h b/src/libtomahawk/artist.h index 28f47fa46..fcd3c6f29 100644 --- a/src/libtomahawk/artist.h +++ b/src/libtomahawk/artist.h @@ -75,6 +75,7 @@ private: QString m_sortname; QByteArray m_coverBuffer; bool m_infoLoaded; + mutable bool m_infoLoading; mutable QString m_uuid; #ifndef ENABLE_HEADLESS