mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-10 08:03:04 -04:00
skin_engine: fix div by 0 for %pP tag
Fixes possible crash during playback with
'Auto-Change Directory' setting enabled.
When the currently playing directory changes, the
skin may be updated on the main thread while the
playback thread is executing create_and_play_dir
and has yet to add any indices to the newly created
playlist.
Introduced in commit 41d5ca3.
Change-Id: I6e930f2db546c7690b362ba8c1a4907d0348ff52
This commit is contained in:
parent
d42dcdcba2
commit
3af4e20792
2 changed files with 5 additions and 7 deletions
|
|
@ -178,7 +178,7 @@ void draw_progressbar(struct gui_wps *gwps, struct skin_viewport* skin_viewport,
|
|||
struct wps_state *state = get_wps_state();
|
||||
struct mp3entry *id3 = state->id3;
|
||||
int x = pb->x, y = pb->y, width = pb->width, height = pb->height;
|
||||
unsigned long length, end;
|
||||
unsigned long end, length = 0;
|
||||
int flags = HORIZONTAL;
|
||||
|
||||
if (height < 0)
|
||||
|
|
@ -221,11 +221,6 @@ void draw_progressbar(struct gui_wps *gwps, struct skin_viewport* skin_viewport,
|
|||
length = pl_total;
|
||||
end = pl_elapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
length = 1;
|
||||
end = 0;
|
||||
}
|
||||
}
|
||||
else if (pb->type == SKIN_TOKEN_PEAKMETER_LEFTBAR ||
|
||||
pb->type == SKIN_TOKEN_PEAKMETER_RIGHTBAR)
|
||||
|
|
@ -281,7 +276,8 @@ void draw_progressbar(struct gui_wps *gwps, struct skin_viewport* skin_viewport,
|
|||
length = id3->length;
|
||||
end = id3->elapsed + state->ff_rewind_count;
|
||||
}
|
||||
else
|
||||
|
||||
if (length <= 0)
|
||||
{
|
||||
length = 1;
|
||||
end = 0;
|
||||
|
|
|
|||
|
|
@ -1354,6 +1354,8 @@ const char *get_token_value(struct gui_wps *gwps,
|
|||
case SKIN_TOKEN_PLAYLIST_PERCENT:
|
||||
{
|
||||
int playlist_amt = playlist_amount();
|
||||
if (playlist_amt <= 0)
|
||||
return NULL;
|
||||
int current_pos = playlist_get_display_index() + offset;
|
||||
int percentage = current_pos * 100 / playlist_amt;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue