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
This commit is contained in:
parent
e213ca4f8b
commit
3a1b3e3807
@ -1144,8 +1144,7 @@ int moveSongInPlaylist(int fd, int from, int to)
|
|||||||
int i;
|
int i;
|
||||||
Song *tmpSong;
|
Song *tmpSong;
|
||||||
int tmpId;
|
int tmpId;
|
||||||
int queuedSong = -1;
|
int currentSong;
|
||||||
int currentSong = -1;
|
|
||||||
|
|
||||||
if (from < 0 || from >= playlist.length) {
|
if (from < 0 || from >= playlist.length) {
|
||||||
commandError(fd, ACK_ERROR_NO_EXIST,
|
commandError(fd, ACK_ERROR_NO_EXIST,
|
||||||
@ -1160,19 +1159,26 @@ int moveSongInPlaylist(int fd, int from, int to)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (from == to) /* no-op */
|
||||||
|
return 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (to < 0) => move to offset from current song
|
* (to < 0) => move to offset from current song
|
||||||
* (-playlist.length == to) => move to position BEFORE current song
|
* (-playlist.length == to) => move to position BEFORE current song
|
||||||
*/
|
*/
|
||||||
if (to < 0 && playlist.current >= 0)
|
currentSong = playlist.order[playlist.current];
|
||||||
to = (playlist.order[playlist.current] + abs(to)) %
|
if (to < 0 && playlist.current >= 0) {
|
||||||
playlist.length;
|
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_state == PLAYLIST_STATE_PLAY) {
|
||||||
if (playlist.queued >= 0) {
|
int queuedSong = -1;
|
||||||
|
|
||||||
|
if (playlist.queued >= 0)
|
||||||
queuedSong = playlist.order[playlist.queued];
|
queuedSong = playlist.order[playlist.queued];
|
||||||
}
|
|
||||||
currentSong = playlist.order[playlist.current];
|
|
||||||
if (queuedSong == from || queuedSong == to
|
if (queuedSong == from || queuedSong == to
|
||||||
|| currentSong == from || currentSong == to) {
|
|| currentSong == from || currentSong == to) {
|
||||||
lockPlaylistInteraction();
|
lockPlaylistInteraction();
|
||||||
|
Loading…
Reference in New Issue
Block a user