1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-16 10:05:22 +00:00

lua-imlib2: Improve Error handling

Each of the following cases cause large numbers of cryptic imlib2
prints, so detect them and print a single error for each.
This commit is contained in:
Simon Lees 2024-02-22 10:57:05 +10:30 committed by Brenden Matthews
parent 755e8c3e10
commit 3397155da4

View File

@ -36,19 +36,40 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y,
Imlib_Image premul;
cairo_surface_t *result;
cairo_t *cr;
auto image = imlib_load_image(file);
if (!image) { return; }
Imlib_Image *image = imlib_load_image(file);
if (!image) {
printf("Error: CairoImageHelper: Couldn't load %s\n", file);
return;
}
if ((scale_x <= 0.0) && (scale_y <= 0.0)) {
printf("Error: CairoImageHelper: Image Scale is 0, %s\n", file);
return;
}
imlib_context_set_image(image);
w = imlib_image_get_width();
h = imlib_image_get_height();
if ((w <= 0) && (h <= 0)) {
printf("Error: CairoImageHelper: %s has 0 size\n", file);
return;
}
scaled_w = *return_scale_w = scale_x * (double)w;
scaled_h = *return_scale_h = scale_y * (double)h;
if ((scaled_w <= 0.0) && (scaled_h <= 0.0)) {
printf("Error: CairoImageHelper: %s scaled image has 0 size\n", file);
return;
}
/* create temporary image */
premul = imlib_create_image(scaled_w, scaled_h);
/* FIXME: add error handling */
if (!premul) {
printf("Error: CairoImageHelper: Couldn't create premul image for %s\n", file);
return;
}
/* fill with opaque black */
imlib_context_set_image(premul);