aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2019-01-29 21:53:50 +0000
committerHarry Jeffery <harry@exec64.co.uk>2019-01-29 22:26:22 +0000
commit5ea3ec05df4d0d39f876e922f4a19022c180e302 (patch)
treebf61faa97a1a6cdb36f9480c56b6c6958e6b8242
parent4461e36a26873a11340397de309a66e11b68c444 (diff)
downloadimv-5ea3ec05df4d0d39f876e922f4a19022c180e302.tar.gz
imv: Improve failed load error handling
-rw-r--r--src/imv.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/imv.c b/src/imv.c
index 737d96c..1f652bc 100644
--- a/src/imv.c
+++ b/src/imv.c
@@ -255,7 +255,8 @@ static void source_callback(struct imv_source_message *msg)
imv->last_source = msg->source;
} else {
event.type = imv->events.BAD_IMAGE;
- event.user.data1 = strdup(msg->error);
+ /* TODO: Something more elegant with error messages */
+ /* event.user.data1 = strdup(msg->error); */
}
SDL_PushEvent(&event);
@@ -944,8 +945,7 @@ static void handle_event(struct imv *imv, SDL_Event *event)
return;
} else if (event->type == imv->events.BAD_IMAGE) {
/* an image failed to load, remove it from our image list */
- char *err_path = event->user.data1;
- imv_navigator_remove(imv->navigator, err_path);
+ const char *err_path = imv_navigator_selection(imv->navigator);
/* special case: the image came from stdin */
if (strcmp(err_path, "-") == 0) {
@@ -956,7 +956,8 @@ static void handle_event(struct imv *imv, SDL_Event *event)
}
fprintf(stderr, "Failed to load image from stdin.\n");
}
- free(err_path);
+
+ imv_navigator_remove(imv->navigator, err_path);
} else if (event->type == imv->events.NEW_PATH) {
/* received a new path from the stdin reading thread */
imv_add_path(imv, event->user.data1);