mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
* Fixed PlaylistInterface::siblingResult() for edge cases.
This commit is contained in:
parent
415b2fcf55
commit
2dabb2645c
@ -61,25 +61,21 @@ Tomahawk::result_ptr
|
||||
PlaylistInterface::siblingResult( int itemsAway, qint64 rootIndex ) const
|
||||
{
|
||||
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.
|
||||
while ( idx >= 0 && safetyCheck != idx )
|
||||
while ( idx >= 0 && !safetyCheck.contains( idx ) )
|
||||
{
|
||||
safetyCheck = idx;
|
||||
safetyCheck << idx;
|
||||
Tomahawk::query_ptr query = queryAt( idx );
|
||||
if ( query && query->numResults() )
|
||||
|
||||
if ( query && query->playable() )
|
||||
{
|
||||
return query->results().first();
|
||||
}
|
||||
|
||||
if ( itemsAway < 0 )
|
||||
itemsAway--;
|
||||
else
|
||||
itemsAway++;
|
||||
|
||||
idx = siblingIndex( itemsAway );
|
||||
idx = siblingIndex( itemsAway < 0 ? -1 : 1, idx );
|
||||
}
|
||||
|
||||
return Tomahawk::result_ptr();
|
||||
|
Loading…
x
Reference in New Issue
Block a user