mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-20 04:41:36 +02:00
Don't endlessely loop on a track when following if the person you're following stops playing. Also don't crash if they go away or time out.
This commit is contained in:
@@ -28,6 +28,7 @@ using namespace Tomahawk;
|
|||||||
SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::source_ptr& source )
|
SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::source_ptr& source )
|
||||||
: PlaylistInterface( this )
|
: PlaylistInterface( this )
|
||||||
, m_source( source )
|
, m_source( source )
|
||||||
|
, m_gotNextSong( false )
|
||||||
{
|
{
|
||||||
connect( source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) );
|
connect( source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) );
|
||||||
}
|
}
|
||||||
@@ -38,12 +39,14 @@ SourcePlaylistInterface::siblingItem( int itemsAway )
|
|||||||
{
|
{
|
||||||
Q_UNUSED( itemsAway );
|
Q_UNUSED( itemsAway );
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if ( m_source->currentTrack()->results().empty() )
|
if ( !m_gotNextSong || m_source.isNull() || m_source->currentTrack().isNull() || m_source->currentTrack()->results().isEmpty() )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << " Results were empty for current track";
|
qDebug() << Q_FUNC_INFO << " Results were empty for current track or source no longer valid";
|
||||||
return Tomahawk::result_ptr();
|
return Tomahawk::result_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_gotNextSong = false;
|
||||||
|
|
||||||
return m_source->currentTrack()->results().first();
|
return m_source->currentTrack()->results().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,12 +55,14 @@ Tomahawk::result_ptr
|
|||||||
SourcePlaylistInterface::nextItem()
|
SourcePlaylistInterface::nextItem()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if ( m_source->currentTrack()->results().empty() )
|
if ( !m_gotNextSong || m_source.isNull() || m_source->currentTrack().isNull() || m_source->currentTrack()->results().isEmpty() )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << " Results were empty for current track";
|
qDebug() << Q_FUNC_INFO << " Results were empty for current track or source no longer valid";
|
||||||
return Tomahawk::result_ptr();
|
return Tomahawk::result_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_gotNextSong = false;
|
||||||
|
|
||||||
return m_source->currentTrack()->results().first();
|
return m_source->currentTrack()->results().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,12 +75,13 @@ SourcePlaylistInterface::tracks()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourcePlaylistInterface::onSourcePlaybackStarted( const Tomahawk::query_ptr& query ) const
|
SourcePlaylistInterface::onSourcePlaybackStarted( const Tomahawk::query_ptr& query )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
connect( query.data(), SIGNAL( resultsAdded( const QList<Tomahawk::result_ptr>& ) ), SLOT( resolveResultsAdded( const QList<Tomahawk::result_ptr>& ) ) );
|
connect( query.data(), SIGNAL( resultsAdded( const QList<Tomahawk::result_ptr>& ) ), SLOT( resolveResultsAdded( const QList<Tomahawk::result_ptr>& ) ) );
|
||||||
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( resolvingFinished( bool ) ) );
|
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( resolvingFinished( bool ) ) );
|
||||||
Pipeline::instance()->resolve( query, true );
|
Pipeline::instance()->resolve( query, true );
|
||||||
|
m_gotNextSong = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -63,12 +63,13 @@ signals:
|
|||||||
void sourceTrackCountChanged( unsigned int tracks );
|
void sourceTrackCountChanged( unsigned int tracks );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSourcePlaybackStarted( const Tomahawk::query_ptr& query ) const;
|
void onSourcePlaybackStarted( const Tomahawk::query_ptr& query );
|
||||||
void resolveResultsAdded( const QList<Tomahawk::result_ptr>& results ) const;
|
void resolveResultsAdded( const QList<Tomahawk::result_ptr>& results ) const;
|
||||||
void resolvingFinished( bool hasResults ) const;
|
void resolvingFinished( bool hasResults ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Tomahawk::source_ptr m_source;
|
Tomahawk::source_ptr m_source;
|
||||||
|
bool m_gotNextSong;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // ns
|
}; // ns
|
||||||
|
Reference in New Issue
Block a user