aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2018-05-08 21:02:54 +0100
committerHarry Jeffery <harry@exec64.co.uk>2018-05-08 21:02:54 +0100
commit716ee2a8f44c0fdcca8222352e20e8aa3e412d86 (patch)
tree055ba2663b1348402d5fa5d9d6df31cecfedaf35
parent713c559c1eed3ea91f470afe729cfbd17f99c4a7 (diff)
downloadimv-716ee2a8f44c0fdcca8222352e20e8aa3e412d86.tar.gz
Handle being passed an empty directory properly
-rw-r--r--src/imv.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/imv.c b/src/imv.c
index 9597026..dc3dedf 100644
--- a/src/imv.c
+++ b/src/imv.c
@@ -548,26 +548,27 @@ int imv_run(struct imv *imv)
break;
}
+ /* if we're out of images, and we're not expecting more from stdin, quit */
+ if(!imv->paths_from_stdin && imv_navigator_length(imv->navigator) == 0) {
+ fprintf(stderr, "No input files left. Exiting.\n");
+ imv->quit = true;
+ continue;
+ }
+
/* if the user has changed image, start loading the new one */
if(imv_navigator_poll_changed(imv->navigator)) {
const char *current_path = imv_navigator_selection(imv->navigator);
- if(!strcmp("", current_path)) {
- if(!imv->paths_from_stdin) {
- fprintf(stderr, "No input files left. Exiting.\n");
- imv->quit = true;
- }
- continue;
+ /* check we got a path back */
+ if(strcmp("", current_path)) {
+ imv_loader_load(imv->loader, current_path,
+ imv->stdin_image_data, imv->stdin_image_data_len);
+ imv->loading = true;
+ imv_viewport_set_playing(imv->view, true);
+
+ char title[1024];
+ generate_env_text(imv, &title[0], sizeof title, imv->title_text);
+ imv_viewport_set_title(imv->view, title);
}
-
-
- imv_loader_load(imv->loader, current_path,
- imv->stdin_image_data, imv->stdin_image_data_len);
- imv->loading = true;
- imv_viewport_set_playing(imv->view, true);
-
- char title[1024];
- generate_env_text(imv, &title[0], sizeof title, imv->title_text);
- imv_viewport_set_title(imv->view, title);
}
if(imv->need_rescale) {