From 04690171c47c99e584fe1ae9d5ebed913ac5ba99 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 7 Sep 2011 22:21:09 +0200 Subject: 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. --- src/slideshow.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/slideshow.c') 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); -- cgit v1.2.3