1
0
Fork 0
forked from len0rd/rockbox

Quickscreen: add more check for case that qs item is not set.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24901 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2010-02-25 06:01:53 +00:00
parent 3849569afc
commit 51bc09e88e

View file

@ -56,7 +56,7 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
struct viewport *vp_icons) struct viewport *vp_icons)
{ {
int char_height, width, pad = 0; int char_height, width, pad = 0;
int left_width, right_width, vert_lines; int left_width = 0, right_width = 0, vert_lines;
unsigned char *s; unsigned char *s;
int nb_lines = viewport_get_nb_lines(parent); int nb_lines = viewport_get_nb_lines(parent);
@ -74,7 +74,6 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
vp_icons->x = parent->x; vp_icons->x = parent->x;
vp_icons->x += (parent->width-CENTER_ICONAREA_SIZE)/2; vp_icons->x += (parent->width-CENTER_ICONAREA_SIZE)/2;
vps[QUICKSCREEN_BOTTOM] = *parent; vps[QUICKSCREEN_BOTTOM] = *parent;
vps[QUICKSCREEN_TOP] = *parent; vps[QUICKSCREEN_TOP] = *parent;
/* depending on the space the top/buttom items use 1 or 2 lines */ /* depending on the space the top/buttom items use 1 or 2 lines */
@ -97,14 +96,19 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
vp_icons->y = vps[QUICKSCREEN_TOP].y vp_icons->y = vps[QUICKSCREEN_TOP].y
+ vps[QUICKSCREEN_TOP].height; + vps[QUICKSCREEN_TOP].height;
vp_icons->height = parent->height - vp_icons->y; vp_icons->height = vps[QUICKSCREEN_BOTTOM].y - vp_icons->y;
vp_icons->height -= parent->height - vps[QUICKSCREEN_BOTTOM].y;
/* adjust the left/right items widths to fit the screen nicely */ /* adjust the left/right items widths to fit the screen nicely */
if (qs->items[QUICKSCREEN_LEFT])
{
s = P2STR(ID2P(qs->items[QUICKSCREEN_LEFT]->lang_id)); s = P2STR(ID2P(qs->items[QUICKSCREEN_LEFT]->lang_id));
left_width = display->getstringsize(s, NULL, NULL); left_width = display->getstringsize(s, NULL, NULL);
}
if (qs->items[QUICKSCREEN_RIGHT])
{
s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id)); s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id));
right_width = display->getstringsize(s, NULL, NULL); right_width = display->getstringsize(s, NULL, NULL);
}
width = MAX(left_width, right_width); width = MAX(left_width, right_width);
if (width*2 + vp_icons->width > parent->width) if (width*2 + vp_icons->width > parent->width)
@ -270,6 +274,9 @@ static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button)
default: default:
return false; return false;
} }
if (qs->items[item] == NULL)
return false;
option_select_next_val(qs->items[item], invert, true); option_select_next_val(qs->items[item], invert, true);
talk_qs_option(qs->items[item], false); talk_qs_option(qs->items[item], false);
return true; return true;
@ -466,4 +473,3 @@ void set_as_qs_item(const struct settings_list *setting,
global_settings.qs_items[item] = i; global_settings.qs_items[item] = i;
} }