From 23fb6aec5676cba1a58e64f7cb9e12b72802aef7 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Wed, 28 Nov 2012 12:48:58 +0100 Subject: [PATCH] * Added a safety check in PlaylistInterface to prevent infinite looping. --- src/libtomahawk/PlaylistInterface.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/PlaylistInterface.cpp b/src/libtomahawk/PlaylistInterface.cpp index 928c19174..80d851805 100644 --- a/src/libtomahawk/PlaylistInterface.cpp +++ b/src/libtomahawk/PlaylistInterface.cpp @@ -58,9 +58,13 @@ Tomahawk::result_ptr PlaylistInterface::siblingResult( int itemsAway ) const { qint64 idx = siblingIndex( itemsAway ); + qint64 safetyCheck = 0; - while ( idx >= 0 ) + // If safetyCheck equals idx, this means the interface keeps returning the same item and we won't discover anything new - abort + // This can happen in repeat / random mode e.g. + while ( idx >= 0 && safetyCheck != idx ) { + safetyCheck = idx; Tomahawk::query_ptr query = queryAt( idx ); if ( query->numResults() ) {