From 8b79bc33f37db12cbb672bdb47dcfeb0f2030bce Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 31 Aug 2011 16:51:58 +0200 Subject: feh_reload_image: Always die if reload failed This fixes a segfault in --reload when the image becomes unloadable while feh is running. Note that this does not affect --reload with more than one file: If the current image is removed, feh will simply jump to the next image. feh will only quit if the file still exists, but can no longer be loaded. --- src/slideshow.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/slideshow.c') diff --git a/src/slideshow.c b/src/slideshow.c index ba9e028..22d2124 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -135,12 +135,12 @@ void cb_reload_timer(void *data) winwidget_rename(w, current_filename); free(current_filename); - feh_reload_image(w, 1, 0); + feh_reload_image(w, 1); feh_add_unique_timer(cb_reload_timer, w, opt.reload); return; } -void feh_reload_image(winwidget w, int resize, int force_new) +void feh_reload_image(winwidget w, int resize) { char *title, *new_title; int len; @@ -152,7 +152,7 @@ void feh_reload_image(winwidget w, int resize, int force_new) return; } - D(("resize %d, force_new %d\n", resize, force_new)); + D(("resize %d\n", resize)); free(FEH_FILE(w->file->data)->caption); FEH_FILE(w->file->data)->caption = NULL; @@ -169,20 +169,10 @@ void feh_reload_image(winwidget w, int resize, int force_new) /* force imlib2 not to cache */ winwidget_free_image(w); - /* if the image has changed in dimensions - we gotta resize */ - if ((feh_load_image(&tmp, FEH_FILE(w->file->data))) == 0) { - if (force_new) { - eprintf("failed to reload image\n"); - } else { - im_weprintf(w, "Couldn't reload image. Is it still there?"); - } - winwidget_rename(w, title); - free(title); - free(new_title); - filelist = feh_file_remove_from_list(filelist, w->file); - return; - } + if ((feh_load_image(&tmp, FEH_FILE(w->file->data))) == 0) + eprintf("failed to reload image"); + /* if the image has changed in dimensions - we gotta resize */ if (!resize && ((old_w != gib_imlib_image_get_width(tmp)) || (old_h != gib_imlib_image_get_height(tmp)))) resize = 1; -- cgit v1.2.3