summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2012-03-28 20:59:17 +0200
committerMichael Stapelberg <michael@stapelberg.de>2012-03-28 21:00:49 +0200
commit3c2436cb71cf37fe4f12eb6b1ccbbe3393ade2b1 (patch)
tree7b2b2f6c12e885ea49f0df0d3c4f48dd6c0722e2
parentbe2195106214b716b23d11534ea004f614b4a0e9 (diff)
Bugfix: fallback when the image cannot be loaded
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.
-rw-r--r--i3lock.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/i3lock.c b/i3lock.c
index bda40a0..895d50a 100644
--- 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