From 3745cd247ed288b6e923f4d59cd60e30e7ffc496 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 31 Mar 2013 05:33:35 +0200 Subject: [PATCH] * Only store results in Pipeline when we're working on temporary queries - e.g. for the rest-API. --- src/libtomahawk/Pipeline.cpp | 28 +++++++++++++++++++++++++--- src/libtomahawk/Pipeline.h | 11 ++--------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/libtomahawk/Pipeline.cpp b/src/libtomahawk/Pipeline.cpp index 44b93812c..676aad2d7 100644 --- a/src/libtomahawk/Pipeline.cpp +++ b/src/libtomahawk/Pipeline.cpp @@ -306,9 +306,13 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results ) if ( !cleanResults.isEmpty() ) { q->addResults( cleanResults ); - foreach ( const result_ptr& r, cleanResults ) + + if ( m_queries_temporary.contains( q ) ) { - m_rids.insert( r->id(), r ); + foreach ( const result_ptr& r, cleanResults ) + { + m_rids.insert( r->id(), r ); + } } if ( q->solved() && !q->isFullTextQuery() ) @@ -552,13 +556,31 @@ Pipeline::decQIDState( const Tomahawk::query_ptr& query ) void Pipeline::onTemporaryQueryTimer() { - QMutexLocker lock( &m_mut ); tDebug() << Q_FUNC_INFO; + + QMutexLocker lock( &m_mut ); m_temporaryQueryTimer.stop(); for ( int i = m_queries_temporary.count() - 1; i >= 0; i-- ) { query_ptr q = m_queries_temporary.takeAt( i ); + m_qids.remove( q->id() ); + foreach ( const Tomahawk::result_ptr& r, q->results() ) + m_rids.remove( r->id() ); } } + + +query_ptr +Pipeline::query( const QID& qid ) const +{ + return m_qids.value( qid ); +} + + +result_ptr +Pipeline::result( const RID& rid ) const +{ + return m_rids.value( rid ); +} diff --git a/src/libtomahawk/Pipeline.h b/src/libtomahawk/Pipeline.h index e08f9412c..e12c28bae 100644 --- a/src/libtomahawk/Pipeline.h +++ b/src/libtomahawk/Pipeline.h @@ -67,15 +67,8 @@ public: void addResolver( Resolver* r ); void removeResolver( Resolver* r ); - query_ptr query( const QID& qid ) const - { - return m_qids.value( qid ); - } - - result_ptr result( const RID& rid ) const - { - return m_rids.value( rid ); - } + query_ptr query( const QID& qid ) const; + result_ptr result( const RID& rid ) const; bool isResolving( const query_ptr& q ) const;