Skip to content

Commit

Permalink
Fixed playlist UI not updating.
Browse files Browse the repository at this point in the history
Now also tries to write to subtracks.
  • Loading branch information
splushii committed Mar 11, 2017
1 parent 1b26c35 commit 4a54906
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions rating.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ rating_action_rate_helper(DB_plugin_action_t *action, int ctx, int rating)
DB_playItem_t *it = NULL;
ddb_playlist_t *plt = NULL;
int num = 0;
int count = 0;
if (ctx == DDB_ACTION_CTX_SELECTION) {
plt = deadbeef->plt_get_curr();
if (plt) {
Expand All @@ -50,13 +51,11 @@ rating_action_rate_helper(DB_plugin_action_t *action, int ctx, int rating)
}
} else if (ctx == DDB_ACTION_CTX_NOWPLAYING) {
it = deadbeef->streamer_get_playing_track();
plt = deadbeef->plt_get_curr();
num = 1;
}
if (!it || !plt || num < 1) {
if (!it || num < 1) {
goto out;
}
int count = 0;
while (it) {
if (deadbeef->pl_is_selected(it) || ctx == DDB_ACTION_CTX_NOWPLAYING) {
if (rating == -1) {
Expand All @@ -73,11 +72,6 @@ rating_action_rate_helper(DB_plugin_action_t *action, int ctx, int rating)
int match = it && dec;
deadbeef->pl_unlock();
if (match) {
int is_subtrack = deadbeef->pl_get_item_flags(it)
& DDB_IS_SUBTRACK;
if (is_subtrack) {
continue;
}
DB_decoder_t *dec = NULL;
DB_decoder_t **decoders = deadbeef->plug_get_decoder_list();
for (int i = 0; decoders[i]; i++) {
Expand All @@ -90,17 +84,17 @@ rating_action_rate_helper(DB_plugin_action_t *action, int ctx, int rating)
}
}
}
count++;
if (count >= num) {
if (++count >= num) {
break;
}
}
DB_playItem_t *next = deadbeef->pl_get_next(it, PL_MAIN);
deadbeef->pl_item_unref(it);
it = next;
}
if (plt) {
deadbeef->plt_modified(plt);
if (count) {
deadbeef->sendmessage(DB_EV_PLAYLISTCHANGED, 0,
DDB_PLAYLIST_CHANGE_CONTENT, 0);
}
out:
if (it) {
Expand Down

0 comments on commit 4a54906

Please sign in to comment.