aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-01-26 12:47:04 +0000
committerEric Wong <normalperson@yhbt.net>2008-01-26 12:47:04 +0000
commit3a1b3e3807609434bf3f392b6b1f66ac218e265c (patch)
tree941a53eeea69e54254ece4689de271b6556496b4 /src
parente213ca4f8bf7b5cf309d6735a64fd799009d398c (diff)
downloadmpd-3a1b3e3807609434bf3f392b6b1f66ac218e265c.tar.gz
mpd-3a1b3e3807609434bf3f392b6b1f66ac218e265c.tar.xz
mpd-3a1b3e3807609434bf3f392b6b1f66ac218e265c.zip
playlist: don't allow no-op/senseless movement of songs
This disables moving the bonkered moving of the current song to a (negative) offset of itself (introduced in the last commit). This also short circuits no-op moves when (from == to) and avoid needless increasing of the playlist version and causes clients to issue pointless no-op plchanges commands. git-svn-id: https://svn.musicpd.org/mpd/trunk@7153 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r--src/playlist.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/playlist.c b/src/playlist.c
index a2dfd0602..0f76c49a0 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -1144,8 +1144,7 @@ int moveSongInPlaylist(int fd, int from, int to)
int i;
Song *tmpSong;
int tmpId;
- int queuedSong = -1;
- int currentSong = -1;
+ int currentSong;
if (from < 0 || from >= playlist.length) {
commandError(fd, ACK_ERROR_NO_EXIST,
@@ -1160,19 +1159,26 @@ int moveSongInPlaylist(int fd, int from, int to)
return -1;
}
+ if (from == to) /* no-op */
+ return 0;
+
/*
* (to < 0) => move to offset from current song
* (-playlist.length == to) => move to position BEFORE current song
*/
- if (to < 0 && playlist.current >= 0)
- to = (playlist.order[playlist.current] + abs(to)) %
- playlist.length;
+ currentSong = playlist.order[playlist.current];
+ if (to < 0 && playlist.current >= 0) {
+ if (currentSong == from)
+ /* no-op, can't be moved to offset of itself */
+ return 0;
+ to = (currentSong + abs(to)) % playlist.length;
+ }
if (playlist_state == PLAYLIST_STATE_PLAY) {
- if (playlist.queued >= 0) {
+ int queuedSong = -1;
+
+ if (playlist.queued >= 0)
queuedSong = playlist.order[playlist.queued];
- }
- currentSong = playlist.order[playlist.current];
if (queuedSong == from || queuedSong == to
|| currentSong == from || currentSong == to) {
lockPlaylistInteraction();