[PATCH 3/3 weston] desktop-shell: Don't spew errors for NULL icon.
Scott Moreau
oreaus at gmail.com
Tue Oct 2 23:20:18 PDT 2012
This avoids spew when a NULL icon is passed to load_icon_or_fallback().
It also avoids using cairo_image_surface_create_from_png() when
CAIRO_HAS_PNG_FUNCTIONS is not defined.
---
clients/desktop-shell.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index 5d2c1f7..89e1ef7 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -584,14 +584,18 @@ panel_create(struct display *display)
static cairo_surface_t *
load_icon_or_fallback(const char *icon)
{
- cairo_surface_t *surface = cairo_image_surface_create_from_png(icon);
+ cairo_surface_t *surface;
cairo_t *cr;
-
- if (cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS)
- return surface;
-
- cairo_surface_destroy(surface);
- fprintf(stderr, "ERROR loading icon from file '%s'\n", icon);
+#ifdef CAIRO_HAS_PNG_FUNCTIONS
+ if (icon) {
+ surface = cairo_image_surface_create_from_png(icon);
+ if (cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS)
+ return surface;
+
+ cairo_surface_destroy(surface);
+ fprintf(stderr, "ERROR loading icon from file '%s'\n", icon);
+ }
+#endif
/* draw fallback icon */
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 20, 20);
--
1.7.11.4
More information about the wayland-devel
mailing list