From 05c04d046f70fa610b3ff89cde7f9ac4b7f252e2 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Mon, 4 Feb 2013 14:21:37 +0100 Subject: [PATCH] Do not report the same tracks multiple times. --- src/libtomahawk/AlbumPlaylistInterface.cpp | 7 +++++-- src/libtomahawk/resolvers/ScriptCommand_AllTracks.cpp | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/AlbumPlaylistInterface.cpp b/src/libtomahawk/AlbumPlaylistInterface.cpp index 1d5d84fd7..8597dadbf 100644 --- a/src/libtomahawk/AlbumPlaylistInterface.cpp +++ b/src/libtomahawk/AlbumPlaylistInterface.cpp @@ -149,7 +149,7 @@ AlbumPlaylistInterface::tracks() const Tomahawk::TracksRequest* cmd = m_collection->requestTracks( ap ); connect( dynamic_cast< QObject* >( cmd ), SIGNAL( tracks( QList ) ), - this, SLOT( onTracksLoaded( QList ) ) ); + this, SLOT( onTracksLoaded( QList ) ), Qt::UniqueConnection ); cmd->enqueue(); } @@ -246,7 +246,7 @@ AlbumPlaylistInterface::infoSystemFinished( const QString& infoId ) Tomahawk::TracksRequest* cmd = m_collection->requestTracks( ap ); connect( dynamic_cast< QObject* >( cmd ), SIGNAL( tracks( QList ) ), - this, SLOT( onTracksLoaded( QList ) ) ); + this, SLOT( onTracksLoaded( QList ) ), Qt::UniqueConnection ); cmd->enqueue(); } @@ -262,6 +262,9 @@ AlbumPlaylistInterface::infoSystemFinished( const QString& infoId ) void AlbumPlaylistInterface::onTracksLoaded( const QList< query_ptr >& tracks ) { +// disconnect( m_collection.data(), SIGNAL( tracksResult( QList< Tomahawk::query_ptr > ) ), +// this, SLOT( onTracksLoaded( QList< Tomahawk::query_ptr > ) ) ); + if ( m_collection.isNull() ) { m_databaseLoaded = true; diff --git a/src/libtomahawk/resolvers/ScriptCommand_AllTracks.cpp b/src/libtomahawk/resolvers/ScriptCommand_AllTracks.cpp index 9a4ee43fb..480fa1065 100644 --- a/src/libtomahawk/resolvers/ScriptCommand_AllTracks.cpp +++ b/src/libtomahawk/resolvers/ScriptCommand_AllTracks.cpp @@ -73,6 +73,8 @@ ScriptCommand_AllTracks::reportFailure() { emit tracks( QList< Tomahawk::query_ptr >() ); emit done(); + disconnect(); + sender()->disconnect( this ); } @@ -81,4 +83,7 @@ ScriptCommand_AllTracks::onResolverDone( const QList< Tomahawk::query_ptr >& q ) { emit tracks( q ); emit done(); + disconnect(); + sender()->disconnect( this ); + //FIXME: find a way to delete this object when its job is done }