From e8bc0dac62f69bfedd95181578cb1b0c9f78a2d3 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 23 Jan 2008 10:48:08 +0100 Subject: [PATCH] check cairo errors --- draw.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/draw.c b/draw.c index a98eb3506..05828deda 100644 --- a/draw.c +++ b/draw.c @@ -267,6 +267,8 @@ draw_image(DrawCtx *ctx, int x, int y, int wanted_h, const char *filename) source = cairo_xlib_surface_create(globalconf.display, ctx->drawable, ctx->visual, ctx->width, ctx->height); surface = cairo_image_surface_create_from_png(filename); + if(cairo_surface_status(surface)) + return; cr = cairo_create (source); if(wanted_h > 0 && (h = cairo_image_surface_get_height(surface)) > 0) { @@ -286,16 +288,19 @@ draw_image(DrawCtx *ctx, int x, int y, int wanted_h, const char *filename) Area draw_get_image_size(const char *filename) { - Area size; + Area size = { -1, -1, -1, -1 }; cairo_surface_t *surface; surface = cairo_image_surface_create_from_png(filename); - cairo_image_surface_get_width(surface); - size.x = 0; - size.y = 0; - size.width = cairo_image_surface_get_width(surface); - size.height = cairo_image_surface_get_height(surface); - cairo_surface_destroy(surface); + if(!cairo_surface_status(surface)) + { + cairo_image_surface_get_width(surface); + size.x = 0; + size.y = 0; + size.width = cairo_image_surface_get_width(surface); + size.height = cairo_image_surface_get_height(surface); + cairo_surface_destroy(surface); + } return size; }