mpd: fix floating point exception when adding random tags/songs
This commit is contained in:
committed by
Andrzej Rybczak
parent
9888c3106e
commit
af17e7eadf
4
NEWS
4
NEWS
@@ -1,3 +1,7 @@
|
||||
ncmpcpp-0.6.3 (????-??-??)
|
||||
|
||||
* Fix floating point exception when adding a specific number of random items.
|
||||
|
||||
ncmpcpp-0.6.2 (2014-12-13)
|
||||
|
||||
* Delete key now aditionally binds by default to action that deletes files in browser.
|
||||
|
||||
@@ -505,7 +505,7 @@ bool Connection::AddRandomTag(mpd_tag_type tag, size_t number)
|
||||
else
|
||||
{
|
||||
std::random_shuffle(tags.begin(), tags.end());
|
||||
auto it = tags.begin()+rand()%(tags.size()-number);
|
||||
auto it = tags.begin();
|
||||
for (size_t i = 0; i < number && it != tags.end(); ++i)
|
||||
{
|
||||
StartSearch(1);
|
||||
@@ -546,7 +546,7 @@ bool Connection::AddRandomSongs(size_t number)
|
||||
{
|
||||
std::random_shuffle(files.begin(), files.end());
|
||||
StartCommandsList();
|
||||
auto it = files.begin()+rand()%(std::max(size_t(1), files.size()-number));
|
||||
auto it = files.begin();
|
||||
for (size_t i = 0; i < number && it != files.end(); ++i, ++it)
|
||||
AddSong(*it);
|
||||
CommitCommandsList();
|
||||
|
||||
Reference in New Issue
Block a user