From d1c4678d82f2c3b7c233f580bee9c5a8c4c42d49 Mon Sep 17 00:00:00 2001 From: emeric Date: Sun, 14 Dec 2014 17:06:12 +0100 Subject: [PATCH] [UI] corrected segfault when enabling shuffle on en empty play queue --- src/ui/audio/PlayQueue.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ui/audio/PlayQueue.cpp b/src/ui/audio/PlayQueue.cpp index 8ea21ac7..3e17d9ef 100644 --- a/src/ui/audio/PlayQueue.cpp +++ b/src/ui/audio/PlayQueue.cpp @@ -111,6 +111,7 @@ class TrackSelector TrackSelector::TrackSelector() : _loop(false), _shuffle(false), +_size(0), _curPos(0) { } @@ -152,10 +153,14 @@ TrackSelector::setShuffle(bool enable) { _shuffle = enable; - if (_shuffle) - setPosByRowId(_curPos); - else - setPos(_trackPos[_curPos]); + if (_size != 0) + { + // Update the current index we are playing if we switch shuffle + if (_shuffle) + setPosByRowId(_curPos); + else + setPos(_trackPos[_curPos]); + } } int