From 96fc2cab17e3c69a38d3a2274dc33956c32f80eb Mon Sep 17 00:00:00 2001 From: Cobinja Date: Mon, 26 Nov 2018 13:37:46 +0100 Subject: Fix background if image file is not readable. This fixes a bug, where we fell back to the defined background color, if reading an image file failed. If that file was a user background, we didn't fall back to the defined system background before using the color, now we do. Only if that one is not readable either, we fall back to the color. Ported from Slick Greeter: https://github.com/linuxmint/slick-greeter/commit/32f2bb5feebca3377c9fc202e0a6aac6ddb75212.patch --- src/background.vala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/background.vala') diff --git a/src/background.vala b/src/background.vala index 6c94831..9a77047 100644 --- a/src/background.vala +++ b/src/background.vala @@ -681,7 +681,25 @@ public class Background : Gtk.Fixed private BackgroundLoader load_background (string? filename) { if (filename == null) + { filename = fallback_bgcolor; + } else + { + try + { + var file = File.new_for_path(filename); + var fileInfo = file.query_info(FileAttribute.ACCESS_CAN_READ, FileQueryInfoFlags.NONE, null); + if (!fileInfo.get_attribute_boolean(FileAttribute.ACCESS_CAN_READ)) + { + debug ("Can't read background file %s, falling back to %s", filename, system_background); + filename = system_background; + } + } + catch + { + filename = system_background; + } + } var b = loaders.lookup (filename); if (b == null) -- cgit v1.2.3