From 3b0449866152f12da625cf15916ad06c167a2d21 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Mon, 28 May 2012 16:32:29 +0200 Subject: [PATCH] * Make sure we always have a working uuid in Artist / Album. --- src/libtomahawk/Album.cpp | 18 +++++++++++++----- src/libtomahawk/Album.h | 1 + src/libtomahawk/Artist.cpp | 25 +++++++++++++++---------- src/libtomahawk/Artist.h | 1 + 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/libtomahawk/Album.cpp b/src/libtomahawk/Album.cpp index ca05f53d8..909f17fe2 100644 --- a/src/libtomahawk/Album.cpp +++ b/src/libtomahawk/Album.cpp @@ -115,14 +115,12 @@ Album::cover( const QSize& size, bool forceLoad ) const if ( !forceLoad ) return QPixmap(); - m_uuid = uuid(); - Tomahawk::InfoSystem::InfoStringHash trackInfo; trackInfo["artist"] = artist()->name(); trackInfo["album"] = name(); Tomahawk::InfoSystem::InfoRequestData requestData; - requestData.caller = m_uuid; + requestData.caller = infoid(); requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt; requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ); requestData.customData = QVariantMap(); @@ -170,7 +168,7 @@ Album::cover( const QSize& size, bool forceLoad ) const void Album::infoSystemInfo( const Tomahawk::InfoSystem::InfoRequestData& requestData, const QVariant& output ) { - if ( requestData.caller != m_uuid || + if ( requestData.caller != infoid() || requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt ) { return; @@ -193,7 +191,7 @@ Album::infoSystemInfo( const Tomahawk::InfoSystem::InfoRequestData& requestData, void Album::infoSystemFinished( const QString& target ) { - if ( target != m_uuid ) + if ( target != infoid() ) return; disconnect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), @@ -230,3 +228,13 @@ Album::tracks( ModelMode mode, const Tomahawk::collection_ptr& collection ) { return playlistInterface( mode, collection )->tracks(); } + + +QString +Album::infoid() const +{ + if ( m_uuid.isEmpty() ) + m_uuid = uuid(); + + return m_uuid; +} \ No newline at end of file diff --git a/src/libtomahawk/Album.h b/src/libtomahawk/Album.h index eae36af96..89c6ad09f 100644 --- a/src/libtomahawk/Album.h +++ b/src/libtomahawk/Album.h @@ -77,6 +77,7 @@ private slots: private: Q_DISABLE_COPY( Album ) + QString infoid() const; unsigned int m_id; QString m_name; diff --git a/src/libtomahawk/Artist.cpp b/src/libtomahawk/Artist.cpp index c36e64ea2..1a85915ad 100644 --- a/src/libtomahawk/Artist.cpp +++ b/src/libtomahawk/Artist.cpp @@ -111,9 +111,6 @@ Artist::albums( ModelMode mode, const Tomahawk::collection_ptr& collection ) con if ( !collection.isNull() ) dbLoaded = false; - m_uuid = uuid(); - tDebug() << Q_FUNC_INFO << mode; - if ( ( mode == DatabaseMode || mode == Mixed ) && !dbLoaded ) { DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection, artist ); @@ -131,7 +128,7 @@ Artist::albums( ModelMode mode, const Tomahawk::collection_ptr& collection ) con artistInfo["artist"] = name(); Tomahawk::InfoSystem::InfoRequestData requestData; - requestData.caller = m_uuid; + requestData.caller = infoid(); requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo ); requestData.type = Tomahawk::InfoSystem::InfoArtistReleases; @@ -171,7 +168,7 @@ Artist::similarArtists() const artistInfo["artist"] = name(); Tomahawk::InfoSystem::InfoRequestData requestData; - requestData.caller = m_uuid; + requestData.caller = infoid(); requestData.customData = QVariantMap(); requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo ); @@ -259,7 +256,7 @@ Artist::onAlbumsFound( const QList< album_ptr >& albums, const QVariant& data ) void Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output ) { - if ( requestData.caller != m_uuid ) + if ( requestData.caller != infoid() ) return; QVariantMap returnedData = output.value< QVariantMap >(); @@ -274,7 +271,6 @@ Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVari QList< album_ptr > albums; foreach ( const QString& albumName, albumNames ) { - tDebug() << Q_FUNC_INFO << albumName; Tomahawk::album_ptr album = Tomahawk::Album::get( m_ownRef.toStrongRef(), albumName, false ); m_officialAlbums << album; albums << album; @@ -328,7 +324,7 @@ Artist::infoSystemFinished( QString target ) { Q_UNUSED( target ); - if ( target != m_uuid ) + if ( target != infoid() ) return; if ( --m_infoJobs == 0 ) @@ -352,13 +348,12 @@ Artist::cover( const QSize& size, bool forceLoad ) const { if ( !forceLoad ) return QPixmap(); - m_uuid = uuid(); Tomahawk::InfoSystem::InfoStringHash trackInfo; trackInfo["artist"] = name(); Tomahawk::InfoSystem::InfoRequestData requestData; - requestData.caller = m_uuid; + requestData.caller = infoid(); requestData.type = Tomahawk::InfoSystem::InfoArtistImages; requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ); requestData.customData = QVariantMap(); @@ -428,3 +423,13 @@ Artist::tracks( ModelMode mode, const Tomahawk::collection_ptr& collection ) { return playlistInterface( mode, collection )->tracks(); } + + +QString +Artist::infoid() const +{ + if ( m_uuid.isEmpty() ) + m_uuid = uuid(); + + return m_uuid; +} diff --git a/src/libtomahawk/Artist.h b/src/libtomahawk/Artist.h index cf267df1e..deeb2fb21 100644 --- a/src/libtomahawk/Artist.h +++ b/src/libtomahawk/Artist.h @@ -88,6 +88,7 @@ private slots: private: Artist(); + QString infoid() const; unsigned int m_id; QString m_name;