summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2024-02-29 15:28:11 +0100
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2024-03-01 11:28:39 +0100
commitee7725862fbc8e246976894d3c6af4027340a329 (patch)
treebefbb69e8cb08dae1d64a2842dd560ec5ca296d7
parent420286e572fb186b6290c72081d22f3f5dd67465 (diff)
MediaPlayerApp example - avoid infinite looping
If we have only 1 file and trying to shuffle, we enter an infinite loop, while trying to find an index not equal to the current one. We need an additional check to avoid this. Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-122178 Change-Id: I299ef0f66adc271be5921a6f16eabde9b2021499 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Mikko Hallamaa <mikko.hallamaa@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
-rw-r--r--examples/demos/mediaplayer/MediaPlayer/PlaylistInfo.qml2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/demos/mediaplayer/MediaPlayer/PlaylistInfo.qml b/examples/demos/mediaplayer/MediaPlayer/PlaylistInfo.qml
index 24013a2fe..cae1efd3d 100644
--- a/examples/demos/mediaplayer/MediaPlayer/PlaylistInfo.qml
+++ b/examples/demos/mediaplayer/MediaPlayer/PlaylistInfo.qml
@@ -26,7 +26,7 @@ Rectangle {
signal currentFileRemoved()
function getSource() {
- if (isShuffled) {
+ if (isShuffled && mediaCount > 1) {
let randomIndex = Math.floor(Math.random() * mediaCount)
while (randomIndex == currentIndex) {
randomIndex = Math.floor(Math.random() * mediaCount)