It was rather inconsistent before. This may help users figure out why
backgrounds and icons don't show up. A better api where the error can
be queried might be nice, but this seems sufficient for current Weston use.
---
 clients/image.c       |    1 -
 shared/image-loader.c |   11 +++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/clients/image.c b/clients/image.c
index 573117c..aee8112 100644
--- a/clients/image.c
+++ b/clients/image.c
@@ -373,7 +373,6 @@ image_create(struct display *display, const char *filename,
        image->image = load_cairo_surface(filename);
 
        if (!image->image) {
-               fprintf(stderr, "could not find the image %s!\n", b);
                free(image->filename);
                free(image);
                return NULL;
diff --git a/shared/image-loader.c b/shared/image-loader.c
index 35dadd3..5d6fbce 100644
--- a/shared/image-loader.c
+++ b/shared/image-loader.c
@@ -23,6 +23,7 @@
 
 #include "config.h"
 
+#include <errno.h>                     
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -374,12 +375,15 @@ load_image(const char *filename)
        FILE *fp;
        unsigned int i;
 
+       if (! filename || ! *filename) return NULL;
+
        fp = fopen(filename, "rb");
-       if (fp == NULL)
-               return NULL;
+       if (fp == NULL) goto ERROR;
 
        if (fread(header, sizeof header, 1, fp) != 1) {
                fclose(fp);
+       ERROR:
+               fprintf(stderr, "%s: %s\n", filename, strerror(errno));
                return NULL;
        }
 
@@ -399,6 +403,9 @@ load_image(const char *filename)
                        "0x%02x 0x%02x 0x%02x 0x%02x\n",
                        filename, header[0], header[1], header[2], header[3]);
                image = NULL;
+       } else if (!image) {
+               /* load probably printed something, but just in case */
+               fprintf(stderr, "error reading image file %s!\n", filename);
        }
 
        return image;
-- 
1.7.9.5

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to