diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-11-08 21:23:02 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-11-08 21:23:02 +0000 |
commit | 1afcd74fdd6ce9d6cf3911076418fb0589da7d17 (patch) | |
tree | c3fa7dade43bcc3baefc9c791de724d38e57ad35 | |
parent | 2e0fff9732486e7653406f194e6a45087ba70470 (diff) | |
download | rockbox-1afcd74fdd6ce9d6cf3911076418fb0589da7d17.tar.gz rockbox-1afcd74fdd6ce9d6cf3911076418fb0589da7d17.zip |
Simplify icon.c a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30934 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/icon.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/apps/gui/icon.c b/apps/gui/icon.c index 284e1979a0..c171da5b44 100644 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c | |||
@@ -176,19 +176,19 @@ void screen_put_cursorxy(struct screen * display, int x, int y, bool on) | |||
176 | 176 | ||
177 | static int buflib_move_callback(int handle, void* current, void* new) | 177 | static int buflib_move_callback(int handle, void* current, void* new) |
178 | { | 178 | { |
179 | (void)current; | 179 | (void)handle; |
180 | (void)new; | 180 | (void)new; |
181 | int i; | 181 | int i; |
182 | FOR_NB_SCREENS(j) | 182 | FOR_NB_SCREENS(j) |
183 | { | 183 | { |
184 | for (i=0; i<Iconset_Count; i++) | 184 | for (i=0; i<Iconset_Count; i++) |
185 | { | 185 | { |
186 | if (iconsets[i][j].handle == handle) | 186 | struct iconset *set = &iconsets[i][j]; |
187 | if (set->bmp.data == current) | ||
187 | { | 188 | { |
188 | if (iconsets[i][j].handle_locked > 0) | 189 | if (set->handle_locked > 0) |
189 | return BUFLIB_CB_CANNOT_MOVE; | 190 | return BUFLIB_CB_CANNOT_MOVE; |
190 | ptrdiff_t diff = new - current; | 191 | set->bmp.data = new; |
191 | iconsets[i][j].bmp.data += diff; | ||
192 | return BUFLIB_CB_OK; | 192 | return BUFLIB_CB_OK; |
193 | } | 193 | } |
194 | } | 194 | } |
@@ -223,17 +223,16 @@ static void load_icons(const char* filename, enum Iconset iconset, | |||
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | lseek(fd, 0, SEEK_SET); | 225 | lseek(fd, 0, SEEK_SET); |
226 | ic->handle_locked = 1; | ||
227 | ic->bmp.data = core_get_data(ic->handle); | 226 | ic->bmp.data = core_get_data(ic->handle); |
228 | 227 | ||
228 | ic->handle_locked = 1; | ||
229 | size_read = read_bmp_fd(fd, &ic->bmp, buf_size, bmpformat, NULL); | 229 | size_read = read_bmp_fd(fd, &ic->bmp, buf_size, bmpformat, NULL); |
230 | if (size_read <= 0) | ||
231 | { | ||
232 | core_free(ic->handle); | ||
233 | return; | ||
234 | } | ||
235 | ic->handle_locked = 0; | 230 | ic->handle_locked = 0; |
236 | ic->loaded = true; | 231 | |
232 | if (size_read <= 0) | ||
233 | ic->handle = core_free(ic->handle); | ||
234 | else | ||
235 | ic->loaded = true; | ||
237 | } | 236 | } |
238 | } | 237 | } |
239 | 238 | ||
@@ -244,13 +243,15 @@ void icons_init(void) | |||
244 | { | 243 | { |
245 | for (i=0; i<Iconset_Count; i++) | 244 | for (i=0; i<Iconset_Count; i++) |
246 | { | 245 | { |
247 | if (iconsets[i][j].loaded && iconsets[i][j].handle > 0) | 246 | struct iconset* set = &iconsets[i][j]; |
247 | if (set->loaded && set->handle > 0) | ||
248 | { | 248 | { |
249 | core_free(iconsets[i][j].handle); | 249 | set->handle = core_free(set->handle); |
250 | iconsets[i][j].loaded = false; | 250 | set->loaded = false; |
251 | } | 251 | } |
252 | } | 252 | } |
253 | } | 253 | } |
254 | |||
254 | load_icons(global_settings.icon_file, Iconset_user, SCREEN_MAIN); | 255 | load_icons(global_settings.icon_file, Iconset_user, SCREEN_MAIN); |
255 | 256 | ||
256 | if (global_settings.viewers_icon_file[0] && | 257 | if (global_settings.viewers_icon_file[0] && |