1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-13 20:41:58 +02:00

Mostly fix TWK-701. A few bugs lined up here.

1) Tracks fetched from an album or artist in DropJob would only fetch from the db
   and never resolve w/ resolvers
2) artist* and album* objects were getting deleted too early if they didn't already exist before
   DropJob asked for them (results from db thread are queued, sharedpointer deletion happened first).
   Keep ahold of them until we're done with them.

For albums we don't know about, we still need to look up metadata track listings when nothing is found in the DB.
This commit is contained in:
Leo Franchi 2012-03-01 00:14:16 -05:00
parent 191ee259d4
commit 6448cebec6
4 changed files with 44 additions and 6 deletions

View File

@ -22,7 +22,6 @@
#include "albumplaylistinterface.h"
#include "database/database.h"
#include "database/databaseimpl.h"
#include "database/databasecommand_alltracks.h"
#include "query.h"
#include "utils/logger.h"

View File

@ -68,7 +68,6 @@ signals:
void nextTrackReady();
private:
Q_DISABLE_COPY( AlbumPlaylistInterface )
AlbumPlaylistInterface();
QList< Tomahawk::query_ptr > m_queries;

View File

@ -39,6 +39,7 @@
#ifdef QCA2_FOUND
#include "utils/groovesharkparser.h"
#include "pipeline.h"
#endif //QCA2_FOUND
@ -126,7 +127,7 @@ DropJob::acceptsMimeData( const QMimeData* data, DropJob::DropTypes acceptedType
// Not the most elegant
if ( url.contains( "spotify" ) && url.contains( "playlist" ) && s_canParseSpotifyPlaylists )
return true;
if ( url.contains( "grooveshark.com" ) && url.contains( "playlist" ) )
return true;
}
@ -573,7 +574,7 @@ DropJob::handleGroovesharkUrls ( const QString& urlsRaw )
#ifdef QCA2_FOUND
QStringList urls = urlsRaw.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
tDebug() << "Got Grooveshark urls!" << urls;
if ( dropAction() == Default )
setDropAction( Create );
@ -693,6 +694,38 @@ DropJob::onTracksAdded( const QList<Tomahawk::query_ptr>& tracksList )
}
void
DropJob::tracksFromDB( const QList< query_ptr >& tracks )
{
// Tracks that we get from databasecommand_alltracks are resolved only against the database and explicitly marked
// as finished. if the source they resolve to is offline they will not resolve against any resolver.
// explicitly resolve them if they fall in that case first
foreach( const query_ptr& track, tracks )
{
if ( !track->playable() && !track->solved() && track->results().size() ) // we have offline results
{
track->setResolveFinished( false );
Pipeline::instance()->resolve( track );
}
}
onTracksAdded( tracks );
if ( Tomahawk::Album* album = qobject_cast< Tomahawk::Album* >( sender() ) )
{
foreach ( const album_ptr& ptr, m_albumsToKeep )
if ( ptr.data() == album )
m_albumsToKeep.remove( ptr );
}
else if ( Tomahawk::Artist* artist = qobject_cast< Tomahawk::Artist* >( sender() ) )
{
foreach ( const artist_ptr& ptr, m_artistsToKeep )
if ( ptr.data() == artist )
m_artistsToKeep.remove( ptr );
}
}
void
DropJob::removeDuplicates()
{
@ -776,8 +809,10 @@ DropJob::getArtist( const QString &artist )
artist_ptr artistPtr = Artist::get( artist );
if ( artistPtr->playlistInterface()->tracks().isEmpty() )
{
m_artistsToKeep.insert( artistPtr );
connect( artistPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
SLOT( tracksFromDB( QList<Tomahawk::query_ptr> ) ) );
m_queryCount++;
return QList< query_ptr >();
}
@ -797,9 +832,11 @@ DropJob::getAlbum(const QString &artist, const QString &album)
if ( albumPtr->playlistInterface()->tracks().isEmpty() )
{
m_albumsToKeep.insert( albumPtr );
m_dropJob = new DropJobNotifier( QPixmap( RESPATH "images/album-icon.png" ), Album );
connect( albumPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
SLOT( tracksFromDB( QList<Tomahawk::query_ptr> ) ) );
JobStatusView::instance()->model()->addJob( m_dropJob );
m_queryCount++;

View File

@ -122,6 +122,7 @@ private slots:
void onTracksAdded( const QList<Tomahawk::query_ptr>& );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void tracksFromDB( const QList< Tomahawk::query_ptr >& );
private:
/// handle parsing mime data
@ -153,6 +154,8 @@ private:
Tomahawk::DropJobNotifier* m_dropJob;
QList< Tomahawk::query_ptr > m_resultList;
QSet< Tomahawk::album_ptr > m_albumsToKeep;
QSet< Tomahawk::artist_ptr > m_artistsToKeep;
static bool s_canParseSpotifyPlaylists;
};