list: reset viewport to avoid corrupting the text in the first line

While using Rockbox for a while on my 1st-gen iPod mini I noticed that
the first entry of a list sometimes displays a wrong character at the
18th column.  For example, the ':' character would display as 'z', the
'-' character as 'm', 0x00 would display '@' and so on.  Oddly enough
this only occurred when the scrollbar was enabled.

I figured that the call to `display->set_viewport(list_text_vp);` in the
for loop inside `list_draw(...)` causes this.  Digging deeper I noticed
that in the `lcd-bitmap-common.c` driver the `current_viewport` was
pointing to the start of the line's text.  From what I can tell the
cause of this was that the viewport was set to a struct with a shorter
scope than the entire function.

The actual fix for this is quite straightforward -- once the scrollbar
has been drawn the viewport is now changed back to the default one.

Change-Id: Id6a7bd8f74864641ea1670fedea9d12d764e78c0
This commit is contained in:
Georg Gadinger 2020-12-12 01:11:46 +01:00 committed by William Wilgus
parent b339400531
commit 512be370c6

View file

@ -216,6 +216,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
indent += SCROLLBAR_WIDTH;
}
display->set_viewport(list_text_vp);
for (i=start; i<end && i<list->nb_items; i++)
{
/* do the text */
@ -246,7 +247,6 @@ void list_draw(struct screen *display, struct gui_synclist *list)
}
line_indent += indent;
display->set_viewport(list_text_vp);
/* position the string at the correct offset place */
int item_width,h;
display->getstringsize(entry_name, &item_width, &h);