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