summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-09-07 22:21:09 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-09-07 22:21:09 +0200
commit04690171c47c99e584fe1ae9d5ebed913ac5ba99 (patch)
tree81de163c7264be14666d4e5305a73d6a12e9b78d
parentf1963a493f82d568befade8d2dc9f601276ac44e (diff)
feh_reload_image: Fix regression of old caching issue (closes #63)
This was broken by the changes allowing --reload to retry ad infinitum. Now force_new is used to decide whether or not to work around the Imlib2 caching issue. Because of this, a few feh_reload_image calls needed to be changed.
-rw-r--r--src/events.c2
-rw-r--r--src/menu.c2
-rw-r--r--src/slideshow.c18
-rw-r--r--src/thumbnail.c2
4 files changed, 16 insertions, 8 deletions
diff --git a/src/events.c b/src/events.c
index c0b1269..def4651 100644
--- a/src/events.c
+++ b/src/events.c
@@ -114,7 +114,7 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
- winwid->im_y) / winwid->old_zoom;
} else if (ev->xbutton.button == opt.reload_button) {
D(("Reload Button Press event\n"));
- feh_reload_image(winwid, 0, 0);
+ feh_reload_image(winwid, 0, 1);
} else if (ev->xbutton.button == opt.prev_button) {
D(("Prev Button Press event\n"));
if (winwid->type == WIN_TYPE_SLIDESHOW)
diff --git a/src/menu.c b/src/menu.c
index 50aa50f..8a3258b 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1302,7 +1302,7 @@ void feh_menu_cb(feh_menu * m, feh_menu_item * i, int action, void *data)
winwidget_render_image(m->fehwin, 1, 0);
break;
case CB_RELOAD:
- feh_reload_image(m->fehwin, 0, 0);
+ feh_reload_image(m->fehwin, 0, 1);
break;
case CB_REMOVE:
feh_filelist_image_remove(m->fehwin, 0);
diff --git a/src/slideshow.c b/src/slideshow.c
index e47b896..e6ffb56 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -171,11 +171,19 @@ void feh_reload_image(winwidget w, int resize, int force_new)
old_w = gib_imlib_image_get_width(w->im);
old_h = gib_imlib_image_get_height(w->im);
- /* if the image has changed in dimensions - we gotta resize */
+ /*
+ * If we don't free the old image before loading the new one, Imlib2's
+ * caching will get in our way.
+ * However, if --reload is used (force_new == 0), we want to continue if
+ * the new image cannot be loaded, so we must not free the old image yet.
+ */
+ if (force_new)
+ winwidget_free_image(w);
+
if ((feh_load_image(&tmp, FEH_FILE(w->file->data))) == 0) {
- if (force_new) {
+ if (force_new)
eprintf("failed to reload image\n");
- } else {
+ else {
im_weprintf(w, "Couldn't reload image. Is it still there?");
winwidget_render_image(w, 0, 0);
}
@@ -189,8 +197,8 @@ void feh_reload_image(winwidget w, int resize, int force_new)
(old_h != gib_imlib_image_get_height(tmp))))
resize = 1;
- /* force imlib2 not to cache */
- winwidget_free_image(w);
+ if (!force_new)
+ winwidget_free_image(w);
w->im = tmp;
winwidget_reset_image(w);
diff --git a/src/thumbnail.c b/src/thumbnail.c
index ee8b101..0c8d00a 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -922,7 +922,7 @@ void feh_thumbnail_show_fullsize(feh_file *thumbfile)
free(thumbwin->file);
thumbwin->file = gib_list_add_front(NULL, thumbfile);
winwidget_rename(thumbwin, s);
- feh_reload_image(thumbwin, 1, 0);
+ feh_reload_image(thumbwin, 1, 1);
}
}