deck: Check if a playqueue is empty before calling next

I need this in case the user deletes all tracks from a playqueue without
adding anything by the time next() is called.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-02-07 20:34:03 -05:00 committed by Anna Schumaker
parent d665b7f167
commit 7d7c83c222
1 changed files with 6 additions and 1 deletions

View File

@ -185,10 +185,15 @@ unsigned int deck :: next()
for (it = playqueue_deck.begin(); it != playqueue_deck.end(); it++) {
if (it->get_flags() & PQ_ENABLED) {
id = it->next();
if (it->size() == 0) {
playqueue_deck.erase(it);
get_callbacks()->on_pq_removed(&(*it));
} else {
id = it->next();
if (it->size() == 0) {
playqueue_deck.erase(it);
get_callbacks()->on_pq_removed(&(*it));
}
}
write();
return id;