diff options
Diffstat (limited to 'apps/gui')
-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] && |