From 0102abeec1d2055b19dccbb7edc7f06e527642b1 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 29 Oct 2017 15:15:28 +0100 Subject: Fix warnings --- main/src/ui/avatar_generator.vala | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'main/src/ui/avatar_generator.vala') diff --git a/main/src/ui/avatar_generator.vala b/main/src/ui/avatar_generator.vala index 7e44f7e2..dce8e3d6 100644 --- a/main/src/ui/avatar_generator.vala +++ b/main/src/ui/avatar_generator.vala @@ -152,16 +152,18 @@ public class AvatarGenerator { Context rectancle_context = new Context(new ImageSurface(Format.ARGB32, width, height)); draw_colored_rectangle(rectancle_context, hex_color, width, height); - Pixbuf icon_pixbuf = IconTheme.get_default().load_icon(icon, ICON_SIZE, IconLookupFlags.FORCE_SIZE); - Surface icon_surface = cairo_surface_create_from_pixbuf(icon_pixbuf, 1, null); - Context context = new Context(icon_surface); - context.set_operator(Operator.IN); - context.set_source_rgba(1, 1, 1, 1); - context.rectangle(0, 0, width, height); - context.fill(); - - rectancle_context.set_source_surface(icon_surface, width / 2 - ICON_SIZE / 2, height / 2 - ICON_SIZE / 2); - rectancle_context.paint(); + try { + Pixbuf icon_pixbuf = IconTheme.get_default().load_icon(icon, ICON_SIZE, IconLookupFlags.FORCE_SIZE); + Surface icon_surface = cairo_surface_create_from_pixbuf(icon_pixbuf, 1, null); + Context context = new Context(icon_surface); + context.set_operator(Operator.IN); + context.set_source_rgba(1, 1, 1, 1); + context.rectangle(0, 0, width, height); + context.fill(); + + rectancle_context.set_source_surface(icon_surface, width / 2 - ICON_SIZE / 2, height / 2 - ICON_SIZE / 2); + rectancle_context.paint(); + } catch (Error e) { warning(@"Icon $icon does not exist"); } return pixbuf_get_from_surface(rectancle_context.get_target(), 0, 0, width, height); } -- cgit v1.2.3-54-g00ecf