]> git.sur5r.net Git - i3/i3lock/commitdiff
Bugfix: fallback when the image cannot be loaded
authorMichael Stapelberg <michael@stapelberg.de>
Wed, 28 Mar 2012 18:59:17 +0000 (20:59 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Wed, 28 Mar 2012 19:00:49 +0000 (21:00 +0200)
If the specified file does not exist or is invalid, previously, the unlock
indicator wouldn’t show up at all, because the invalid surface was still used.

With this commit, i3lock will react like if you didn’t specify an image at all.

i3lock.c

index bda40a0a826c37907ecaa929fc696537263c6cb4..895d50ac2d1990264f4075b8ce0dcec0ef6233df 100644 (file)
--- a/i3lock.c
+++ b/i3lock.c
@@ -688,6 +688,13 @@ int main(int argc, char *argv[]) {
     if (image_path) {
         /* Create a pixmap to render on, fill it with the background color */
         img = cairo_image_surface_create_from_png(image_path);
+        /* In case loading failed, we just pretend no -i was specified. */
+        if (cairo_surface_status(img) != CAIRO_STATUS_SUCCESS) {
+            if (debug_mode)
+                fprintf(stderr, "Could not load image \"%s\": cairo surface status %d\n",
+                        image_path, cairo_surface_status(img));
+            img = NULL;
+        }
     }
 #endif