1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 09:04:33 +02:00

Don't repeat scriptcollection queries when an album has no tracks.

This should never happen with sane data.
This commit is contained in:
Teo Mrnjavac
2013-04-04 12:44:52 +02:00
parent 3f48d1a3ad
commit a47e1043fc
2 changed files with 7 additions and 1 deletions

View File

@@ -43,6 +43,7 @@ AlbumPlaylistInterface::AlbumPlaylistInterface( Tomahawk::Album* album, Tomahawk
, m_mode( mode ) , m_mode( mode )
, m_collection( collection ) , m_collection( collection )
, m_album( QPointer< Tomahawk::Album >( album ) ) , m_album( QPointer< Tomahawk::Album >( album ) )
, m_lastQueryTimestamp( 0 )
{ {
} }
@@ -108,7 +109,7 @@ AlbumPlaylistInterface::setCurrentTrack( unsigned int albumpos )
QList< Tomahawk::query_ptr > QList< Tomahawk::query_ptr >
AlbumPlaylistInterface::tracks() const AlbumPlaylistInterface::tracks() const
{ {
if ( m_queries.isEmpty() && m_album ) if ( m_queries.isEmpty() && m_album && QDateTime::currentMSecsSinceEpoch() - m_lastQueryTimestamp > 10000 /*10s*/ )
{ {
if ( ( m_mode == Mixed || m_mode == InfoSystemMode ) && !m_infoSystemLoaded ) if ( ( m_mode == Mixed || m_mode == InfoSystemMode ) && !m_infoSystemLoaded )
{ {
@@ -131,6 +132,8 @@ AlbumPlaylistInterface::tracks() const
connect( Tomahawk::InfoSystem::InfoSystem::instance(), connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( finished( QString ) ), SIGNAL( finished( QString ) ),
SLOT( infoSystemFinished( QString ) ) ); SLOT( infoSystemFinished( QString ) ) );
const_cast< int& >( m_lastQueryTimestamp ) = QDateTime::currentMSecsSinceEpoch();
} }
else if ( m_mode == DatabaseMode && !m_databaseLoaded ) else if ( m_mode == DatabaseMode && !m_databaseLoaded )
{ {
@@ -153,6 +156,7 @@ AlbumPlaylistInterface::tracks() const
cmd->enqueue(); cmd->enqueue();
} }
const_cast< int& >( m_lastQueryTimestamp ) = QDateTime::currentMSecsSinceEpoch();
} }
} }

View File

@@ -82,6 +82,8 @@ private:
Tomahawk::collection_ptr m_collection; Tomahawk::collection_ptr m_collection;
QPointer< Tomahawk::Album > m_album; QPointer< Tomahawk::Album > m_album;
int m_lastQueryTimestamp; //To prevent infinite loops on empty responses. This should not happen, but let's make sure.
}; };
}; // ns }; // ns