mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* Fixed PlaylistInterface::siblingResult() for edge cases.
This commit is contained in:
@@ -61,25 +61,21 @@ Tomahawk::result_ptr
|
|||||||
PlaylistInterface::siblingResult( int itemsAway, qint64 rootIndex ) const
|
PlaylistInterface::siblingResult( int itemsAway, qint64 rootIndex ) const
|
||||||
{
|
{
|
||||||
qint64 idx = siblingIndex( itemsAway, rootIndex );
|
qint64 idx = siblingIndex( itemsAway, rootIndex );
|
||||||
qint64 safetyCheck = -1;
|
QList< qint64 > safetyCheck;
|
||||||
|
|
||||||
// If safetyCheck equals idx, this means the interface keeps returning the same item and we won't discover anything new - abort
|
// If safetyCheck contains idx, this means the interface keeps returning the same items and we won't discover anything new - abort
|
||||||
// This can happen in repeat / random mode e.g.
|
// This can happen in repeat / random mode e.g.
|
||||||
while ( idx >= 0 && safetyCheck != idx )
|
while ( idx >= 0 && !safetyCheck.contains( idx ) )
|
||||||
{
|
{
|
||||||
safetyCheck = idx;
|
safetyCheck << idx;
|
||||||
Tomahawk::query_ptr query = queryAt( idx );
|
Tomahawk::query_ptr query = queryAt( idx );
|
||||||
if ( query && query->numResults() )
|
|
||||||
|
if ( query && query->playable() )
|
||||||
{
|
{
|
||||||
return query->results().first();
|
return query->results().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( itemsAway < 0 )
|
idx = siblingIndex( itemsAway < 0 ? -1 : 1, idx );
|
||||||
itemsAway--;
|
|
||||||
else
|
|
||||||
itemsAway++;
|
|
||||||
|
|
||||||
idx = siblingIndex( itemsAway );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Tomahawk::result_ptr();
|
return Tomahawk::result_ptr();
|
||||||
|
Reference in New Issue
Block a user