freemyipod r703 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r702‎ | r703 | r704 >
Date:03:10, 24 April 2011
Author:theseven
Status:new
Tags:
Comment:
libui: Fix a race condition, which was responsible for boot menu crashes
Modified paths:
  • /libs/ui/chooser_renderer_iconflow.c (modified) (history)
  • /libs/ui/chooser_renderer_list.c (modified) (history)

Diff [purge]

Index: libs/ui/chooser_renderer_list.c
@@ -82,9 +82,10 @@
8383 {
8484 const struct chooser_renderer_list_params* params;
8585 params = (const struct chooser_renderer_list_params*)(data->info->rendererparams);
 86+ const struct chooser_item* selected = data->selected;
8687 struct chooser_renderer_list_data* rdata;
8788 rdata = (struct chooser_renderer_list_data*)(data->rendererdata);
88 - chooser_renderer_list_scroll_into_view(data, data->selected);
 89+ chooser_renderer_list_scroll_into_view(data, selected);
8990 const struct chooser_item* item = rdata->top_item;
9091 if (params->copy_dest.buf.addr == params->fill_dest.loc.buf.addr
9192 && params->copy_dest.buf.stride == params->fill_dest.loc.buf.stride
@@ -157,7 +158,7 @@
158159 uint32_t text_color;
159160 const struct libui_surface* icon;
160161 int icon_opacity;
161 - if (item == data->selected)
 162+ if (item == selected)
162163 {
163164 fill_color = iparams->fill_color_selected;
164165 text_color = iparams->text_color_selected;
Index: libs/ui/chooser_renderer_iconflow.c
@@ -73,6 +73,7 @@
7474 rdata->lastupdate = time;
7575 if (data->position - rdata->viewposition) rc = CHOOSER_RESULT_REDRAW;
7676 else rdata->lastupdate = 0;
 77+ const struct chooser_item* selected = data->selected;
7778 if (params->copy_dest.buf.addr == params->fill_dest.loc.buf.addr
7879 && params->copy_dest.buf.stride == params->fill_dest.loc.buf.stride
7980 && params->copy_dest.pos.x == params->fill_dest.loc.pos.x
@@ -147,7 +148,7 @@
148149 const struct chooser_item* item = data->info->items;
149150 while (true)
150151 {
151 - if (item == data->selected && dir == 1)
 152+ if (item == selected && dir == 1)
152153 {
153154 dir = -1;
154155 item = &data->info->items[data->info->itemcount - 1];
@@ -155,12 +156,12 @@
156157 }
157158 iparams = (const struct chooser_renderer_iconflow_itemdata*)(item->renderparams);
158159 const struct libui_surface* icon;
159 - if (item == data->selected) icon = &iparams->icon_selected;
 160+ if (item == selected) icon = &iparams->icon_selected;
160161 else icon = &iparams->icon;
161162 int ix, iy, io;
162163 int dist = pos - vpos;
163164 chooser_renderer_iconflow_geticondata(x, y, w, h, spi * iiv, dist, icon, &ix, &iy, &io);
164 - if (item == data->selected)
 165+ if (item == selected)
165166 {
166167 io = 255;
167168 if (iparams->text && iparams->text_color)
@@ -171,7 +172,7 @@
172173 && ix + icon->size.x <= x + w && iy + icon->size.y <= y + h)
173174 blenda(icon->size.x, icon->size.y, io, buf, ix, iy, stride, buf, ix, iy, stride,
174175 icon->loc.buf.addr, icon->loc.pos.x, icon->loc.pos.y, icon->loc.buf.stride);
175 - if (item == data->selected) break;
 176+ if (item == selected) break;
176177 item += dir;
177178 pos += dir * spi;
178179 }
@@ -190,6 +191,7 @@
191192 const struct chooser_renderer_iconflow_params* params;
192193 params = (const struct chooser_renderer_iconflow_params*)(data->info->rendererparams);
193194 if (x >= params->viewport.size.x || y >= params->viewport.size.y) return NULL;
 195+ const struct chooser_item* selected = data->selected;
194196 struct chooser_renderer_iconflow_data* rdata;
195197 rdata = (struct chooser_renderer_iconflow_data*)(data->rendererdata);
196198 const struct chooser_item* result = NULL;
@@ -206,7 +208,7 @@
207209 const struct chooser_item* item = data->info->items;
208210 while (true)
209211 {
210 - if (item == data->selected && dir == 1)
 212+ if (item == selected && dir == 1)
211213 {
212214 dir = -1;
213215 item = &data->info->items[data->info->itemcount - 1];
@@ -214,13 +216,13 @@
215217 }
216218 iparams = (const struct chooser_renderer_iconflow_itemdata*)(item->renderparams);
217219 const struct libui_surface* icon;
218 - if (item == data->selected) icon = &iparams->icon_selected;
 220+ if (item == selected) icon = &iparams->icon_selected;
219221 else icon = &iparams->icon;
220222 int ix, iy, o;
221223 int dist = pos - vpos;
222224 chooser_renderer_iconflow_geticondata(vx, vy, vw, vh, spi * iiv, dist, icon, &ix, &iy, &o);
223225 if (x >= ix && y >= ix && x < ix + icon->size.x && y < iy + icon->size.y) result = item;
224 - if (item == data->selected) break;
 226+ if (item == selected) break;
225227 item += dir;
226228 pos += dir * spi;
227229 }