[gnome-documents] utils: be more robust against missing icons in gnome-icon-theme-symbolic



commit 9d879a49bc0483a0c0502a4c4348587b5b1a4958
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Apr 2 10:37:33 2012 -0400

    utils: be more robust against missing icons in gnome-icon-theme-symbolic
    
    When an icon is not found, we currently segfault, since we try to load a
    NULL GtkIconInfo. Avoid that, and at the same time use
    g_themed_icon_new_with_default_fallbacks() to possibly get a fallback
    icon in case the symbolic one is not found.

 src/lib/gd-utils.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/lib/gd-utils.c b/src/lib/gd-utils.c
index 563573d..6b209ac 100644
--- a/src/lib/gd-utils.c
+++ b/src/lib/gd-utils.c
@@ -568,16 +568,19 @@ gd_create_symbolic_icon (const gchar *name,
   gtk_render_background (style, cr, (total_size - bg_size) / 2, (total_size - bg_size) / 2, bg_size, bg_size);
 
   symbolic_name = g_strconcat (name, "-symbolic", NULL);
-  icon = g_themed_icon_new (symbolic_name);
+  icon = g_themed_icon_new_with_default_fallbacks (symbolic_name);
+  g_free (symbolic_name);
 
   theme = gtk_icon_theme_get_default();
   info = gtk_icon_theme_lookup_by_gicon (theme, icon, emblem_size,
                                          GTK_ICON_LOOKUP_FORCE_SIZE);
-  pixbuf = gtk_icon_info_load_symbolic_for_context (info, style, NULL, NULL);
+  g_object_unref (icon);
 
+  if (info == NULL)
+    goto out;
+
+  pixbuf = gtk_icon_info_load_symbolic_for_context (info, style, NULL, NULL);
   gtk_icon_info_free (info);
-  g_object_unref (icon);
-  g_free (symbolic_name);
 
   if (pixbuf == NULL)
     goto out;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]