From 9cad342056cf041b3696cdfae408b6c9c7315e1c Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Fri, 23 Jan 2009 00:07:10 +0100
Subject: [PATCH] playlist: recalculate the queued song after random is toggled

When the random mode is toggled, MPD did not clear the queue.  Because
of this, MPD continued with the next (random or non-random) song
according to the previous mode.  Clear the queued song to fix that.
---
 NEWS           | 1 +
 src/playlist.c | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/NEWS b/NEWS
index f3b5c58f9..257343672 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,7 @@ ver 0.15 - (200?/??/??)
 * failure to read the state file is non-fatal
 * --create-db starts the MPD daemon instead of exiting
 * playlist_directory and music_directory are optional
+* playlist: recalculate the queued song after random is toggled
 
 
 ver 0.14.1 (2009/01/17)
diff --git a/src/playlist.c b/src/playlist.c
index 3f18f6b81..cce2924c1 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -951,6 +951,9 @@ void setPlaylistRandomStatus(bool status)
 	if (status == playlist.queue.random)
 		return;
 
+	if (playlist.queued >= 0)
+		clearPlayerQueue();
+
 	playlist.queue.random = status;
 
 	if (playlist.queue.random) {