From 89876fc7d6922995d6c253a222a608153772227d Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Tue, 20 Jun 2017 15:36:01 +0200 Subject: src/background.vala: No runtime warning on empty background image filename. Ported from slick-greeter. --- src/background.vala | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/background.vala') diff --git a/src/background.vala b/src/background.vala index 967e9f9..0c722e8 100644 --- a/src/background.vala +++ b/src/background.vala @@ -439,14 +439,16 @@ public class Background : Gtk.Fixed width = height = 0; try { - var image = new Gdk.Pixbuf.from_file (filename); - width = image.width; - height = image.height; - var surface = new Cairo.Surface.similar (target_surface, Cairo.Content.COLOR_ALPHA, image.width, image.height); - var c = new Cairo.Context (surface); - Gdk.cairo_set_source_pixbuf (c, image, 0, 0); - c.paint (); - return surface; + if (filename != "") { + var image = new Gdk.Pixbuf.from_file (filename); + width = image.width; + height = image.height; + var surface = new Cairo.Surface.similar (target_surface, Cairo.Content.COLOR_ALPHA, image.width, image.height); + var c = new Cairo.Context (surface); + Gdk.cairo_set_source_pixbuf (c, image, 0, 0); + c.paint (); + return surface; + } } catch (Error e) { -- cgit v1.2.3