fix assertion failure while trying to send play command in commands list
this fixes #3746
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
#include "playlist.h"
|
||||
#include "statusbar.h"
|
||||
|
||||
bool addSongToPlaylist(const MPD::Song &s, bool play, size_t position)
|
||||
bool addSongToPlaylist(const MPD::Song &s, bool play, int position)
|
||||
{
|
||||
bool result = false;
|
||||
if (Config.ncmpc_like_songs_adding && myPlaylist->checkForSong(s))
|
||||
@@ -49,7 +49,6 @@ bool addSongToPlaylist(const MPD::Song &s, bool play, size_t position)
|
||||
}
|
||||
else
|
||||
{
|
||||
position = std::min(position, myPlaylist->main().size());
|
||||
int id = Mpd.AddSong(s, position);
|
||||
if (id >= 0)
|
||||
{
|
||||
@@ -64,18 +63,32 @@ bool addSongToPlaylist(const MPD::Song &s, bool play, size_t position)
|
||||
return result;
|
||||
}
|
||||
|
||||
void addSongsToPlaylist(const MPD::SongList &list, bool play, size_t position)
|
||||
void addSongsToPlaylist(const MPD::SongList &list, bool play, int position)
|
||||
{
|
||||
if (list.size() >= 1)
|
||||
{
|
||||
int id = Mpd.AddSong(list.front(), position);
|
||||
if (id > 0)
|
||||
{
|
||||
if (list.empty())
|
||||
return;
|
||||
position = std::min(position, myPlaylist->main().size());
|
||||
Mpd.StartCommandsList();
|
||||
for (auto s = list.rbegin(); s != list.rend(); ++s)
|
||||
if (position == -1)
|
||||
{
|
||||
for (auto s = list.begin()+1; s != list.end(); ++s)
|
||||
if (Mpd.AddSong(*s) < 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto end = list.rend()-1;
|
||||
for (auto s = list.rbegin(); s != end; ++s)
|
||||
if (Mpd.AddSong(*s, position) < 0)
|
||||
break;
|
||||
if (play)
|
||||
Mpd.Play(position);
|
||||
}
|
||||
Mpd.CommitCommandsList();
|
||||
if (play)
|
||||
Mpd.PlayID(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string Timestamp(time_t t)
|
||||
|
||||
@@ -457,8 +457,8 @@ template <typename BufferT> void ShowTag(BufferT &buf, const std::string &tag)
|
||||
buf << tag;
|
||||
}
|
||||
|
||||
bool addSongToPlaylist(const MPD::Song &s, bool play, size_t position = -1);
|
||||
void addSongsToPlaylist(const MPD::SongList &list, bool play, size_t position = -1);
|
||||
bool addSongToPlaylist(const MPD::Song &s, bool play, int position = -1);
|
||||
void addSongsToPlaylist(const MPD::SongList &list, bool play, int position = -1);
|
||||
|
||||
std::string Timestamp(time_t t);
|
||||
|
||||
|
||||
@@ -298,9 +298,15 @@ void Status::Changes::playlist()
|
||||
if (isVisible(mySearcher))
|
||||
markSongsInPlaylist(mySearcher->proxySongList());
|
||||
if (isVisible(myLibrary))
|
||||
{
|
||||
markSongsInPlaylist(myLibrary->songsProxyList());
|
||||
myLibrary->Songs.refresh();
|
||||
}
|
||||
if (isVisible(myPlaylistEditor))
|
||||
{
|
||||
markSongsInPlaylist(myPlaylistEditor->contentProxyList());
|
||||
myPlaylistEditor->Content.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void Status::Changes::storedPlaylists()
|
||||
|
||||
Reference in New Issue
Block a user