[gtk+] css: Handle image loading errors graciously
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] css: Handle image loading errors graciously
- Date: Thu, 21 Jan 2016 13:21:55 +0000 (UTC)
commit 419f2c670dcfe7975bb31970991d844f5e38c74e
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jan 21 08:18:46 2016 -0500
css: Handle image loading errors graciously
If we fail to load the image for a -gtk-recolor() expression,
fall back to using the image-missing icon instead of crashing,
and include more details in the warning message.
gtk/gtkcssimagerecolor.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssimagerecolor.c b/gtk/gtkcssimagerecolor.c
index 0d6948a..306e7ab 100644
--- a/gtk/gtkcssimagerecolor.c
+++ b/gtk/gtkcssimagerecolor.c
@@ -108,17 +108,25 @@ gtk_css_image_recolor_load (GtkCssImageRecolor *recolor,
GdkRGBA fg, success, warning, error;
GdkPixbuf *pixbuf;
GtkCssImage *image;
+ GError *gerror = NULL;
lookup_symbolic_colors (style, palette, &fg, &success, &warning, &error);
info = gtk_icon_info_new_for_file (url->file, 0, 1);
- pixbuf = gtk_icon_info_load_symbolic (info, &fg, &success, &warning, &error, NULL, NULL);
+ pixbuf = gtk_icon_info_load_symbolic (info, &fg, &success, &warning, &error, NULL, &gerror);
g_object_unref (info);
if (pixbuf == NULL)
{
- g_warning ("Failed to load icon");
- return NULL;
+ char *uri;
+
+ /* XXX: Get the error somehow back to the CssProvider */
+ uri = g_file_get_uri (url->file);
+ g_warning ("Error loading image '%s': %s\n", uri, gerror->message);
+ g_error_free (gerror);
+ g_free (uri);
+
+ pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "image-missing", 24, 0, NULL);
}
image = _gtk_css_image_surface_new_for_pixbuf (pixbuf);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]