summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-08-31 16:51:58 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-08-31 16:58:11 +0200
commit8b79bc33f37db12cbb672bdb47dcfeb0f2030bce (patch)
tree7fe42adc6685cdc4da86cad0e24a47ce035e1290 /src
parent232302e9b8e81fe7c712d3659164dea3d007b0fe (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/events.c2
-rw-r--r--src/feh.h2
-rw-r--r--src/imlib.c4
-rw-r--r--src/keyevents.c6
-rw-r--r--src/menu.c2
-rw-r--r--src/signals.c2
-rw-r--r--src/slideshow.c22
-rw-r--r--src/thumbnail.c2
8 files changed, 16 insertions, 26 deletions
diff --git a/src/events.c b/src/events.c
index 96408e1..68f8c11 100644
--- a/src/events.c
+++ b/src/events.c
@@ -127,7 +127,7 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
} else if (ev->xbutton.button == opt.reload_button) {
D(("Reload Button Press event\n"));
if (winwid != NULL)
- feh_reload_image(winwid, 0, 0);
+ feh_reload_image(winwid, 0);
} else if (ev->xbutton.button == opt.prev_button) {
D(("Prev Button Press event\n"));
if ((winwid != NULL)
diff --git a/src/feh.h b/src/feh.h
index 6604f66..c1ca034 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -146,7 +146,7 @@ void feh_draw_info(winwidget w);
void feh_draw_errstr(winwidget w);
void feh_display_status(char stat);
void real_loadables_mode(int loadable);
-void feh_reload_image(winwidget w, int resize, int force_new);
+void feh_reload_image(winwidget w, int resize);
void feh_filelist_image_remove(winwidget winwid, char do_delete);
void slideshow_save_image(winwidget win);
void feh_edit_inplace(winwidget w, int orientation);
diff --git a/src/imlib.c b/src/imlib.c
index 47031bd..ed3fc12 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -801,7 +801,7 @@ void feh_edit_inplace(winwidget w, int op)
if (!strcmp(gib_imlib_image_format(w->im), "jpeg")) {
feh_edit_inplace_lossless(w, op);
- feh_reload_image(w, 1, 1);
+ feh_reload_image(w, 1);
return;
}
@@ -817,7 +817,7 @@ void feh_edit_inplace(winwidget w, int op)
gib_imlib_image_orientate(old, op);
gib_imlib_save_image(old, FEH_FILE(w->file->data)->filename);
gib_imlib_free_image(old);
- feh_reload_image(w, 1, 1);
+ feh_reload_image(w, 1);
} else {
im_weprintf(w, "failed to load image from disk to edit it in place");
}
diff --git a/src/keyevents.c b/src/keyevents.c
index 60663db..8e6e3f6 100644
--- a/src/keyevents.c
+++ b/src/keyevents.c
@@ -333,7 +333,7 @@ void feh_event_invoke_action(winwidget winwid, unsigned char action)
feh_action_run(FEH_FILE(winwid->file->data), opt.actions[action]);
if (opt.hold_actions[action])
- feh_reload_image(winwid, 1, 1);
+ feh_reload_image(winwid, 1);
else
slideshow_change_image(winwid, SLIDE_NEXT, 1);
@@ -342,7 +342,7 @@ void feh_event_invoke_action(winwidget winwid, unsigned char action)
feh_action_run(FEH_FILE(winwid->file->data), opt.actions[action]);
if (opt.hold_actions[action])
- feh_reload_image(winwid, 1, 1);
+ feh_reload_image(winwid, 1);
else
winwidget_destroy(winwid);
} else if (winwid->type == WIN_TYPE_THUMBNAIL)
@@ -630,7 +630,7 @@ void feh_event_handle_keypress(XEvent * ev)
winwidget_render_image(winwid, 0, 0);
}
else if (feh_is_kp(&keys.reload_image, keysym, state)) {
- feh_reload_image(winwid, 0, 0);
+ feh_reload_image(winwid, 0);
}
else if (feh_is_kp(&keys.toggle_pause, keysym, state)) {
slideshow_pause_toggle(winwid);
diff --git a/src/menu.c b/src/menu.c
index 16e1c77..4a2c38f 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);
break;
case CB_REMOVE:
feh_filelist_image_remove(m->fehwin, 0);
diff --git a/src/signals.c b/src/signals.c
index d5a6899..01cdf72 100644
--- a/src/signals.c
+++ b/src/signals.c
@@ -70,7 +70,7 @@ void feh_handle_signal(int signo)
slideshow_change_image(winwid, SLIDE_PREV, 1);
} else if (opt.multiwindow) {
for (i = window_num - 1; i >= 0; i--)
- feh_reload_image(windows[i], 0, 0);
+ feh_reload_image(windows[i], 0);
}
return;
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;
diff --git a/src/thumbnail.c b/src/thumbnail.c
index ee8b101..9053649 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);
}
}