From a732e75d8a484c9e9a1c281d93124580fad83dd4 Mon Sep 17 00:00:00 2001 From: Bert Date: Thu, 20 Jan 2011 16:24:48 +0100 Subject: Check all given files before open the first --- image.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'image.c') diff --git a/image.c b/image.c index 953b1c2..7b0df5d 100644 --- a/image.c +++ b/image.c @@ -39,22 +39,26 @@ void imlib_destroy() { imlib_free_image(); } -void img_load(img_t *img, const char *filename) { +int img_load(img_t *img, const char *filename) { Imlib_Image *im; if (!img || !filename) - return; + return -1; if (imlib_context_get_image()) imlib_free_image(); - if (!(im = imlib_load_image(filename))) - DIE("could not open image: %s", filename); + if (!(im = imlib_load_image(filename))) { + WARN("could not open image: %s", filename); + return -1; + } imlib_context_set_image(im); img->w = imlib_image_get_width(); img->h = imlib_image_get_height(); + + return 0; } void img_display(img_t *img, win_t *win) { -- cgit v1.2.3