[gimp/gimp-2-10] libgimpwidgets: check error return for gtk_icon_theme_load_icon().



commit 98e955aebfeeb57afd1095eda705324afae6c5f6
Author: Jehan <jehan girinstud io>
Date:   Sat Oct 12 11:59:53 2019 +0200

    libgimpwidgets: check error return for gtk_icon_theme_load_icon().
    
    In gimp_page_selector_add_frame(), if "gimp-frame" icon cannot be loaded
    (which should not happen, but reality can always strike back!), we want
    to abort from gimp_page_selector_add_frame() immediately.
    
    Also as a consequence, its return value might be NULL, hence should be
    freed with g_clear_object() instead.
    
    This happened here because of broken meson rules (which didn't install
    this icon) and ended up in forever looping errors when loading a
    multi-page PDF (pages are shown in frames in a dialog):
    
    > (file-pdf-load:12348): GdkPixbuf-CRITICAL **: 11:59:28.513: gdk_pixbuf_copy_area: assertion 'src_pixbuf 
!= NULL' failed
    
    (cherry picked from commit 9dcdf37ab3f8dc32031206d1c6a224b7a67a5b5f)

 libgimpwidgets/gimppageselector.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/libgimpwidgets/gimppageselector.c b/libgimpwidgets/gimppageselector.c
index 03b6a5693f..c8827810e1 100644
--- a/libgimpwidgets/gimppageselector.c
+++ b/libgimpwidgets/gimppageselector.c
@@ -574,7 +574,7 @@ gimp_page_selector_set_page_thumbnail (GimpPageSelector *selector,
   gtk_list_store_set (priv->store, &iter,
                       COLUMN_THUMBNAIL, thumbnail,
                       -1);
-  g_object_unref (thumbnail);
+  g_clear_object (&thumbnail);
 }
 
 /**
@@ -1298,8 +1298,16 @@ gimp_page_selector_add_frame (GtkWidget *widget,
 
   if (! frame)
     {
+      GError *error = NULL;
+
       frame = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-                                        GIMP_ICON_FRAME, 64, 0, NULL);
+                                        GIMP_ICON_FRAME, 64, 0, &error);
+      if (error)
+        {
+          g_printerr ("%s: %s\n", G_STRFUNC, error->message);
+          g_error_free (error);
+        }
+      g_return_val_if_fail (frame, NULL);
       g_object_set_data_full (G_OBJECT (widget), "frame", frame,
                               (GDestroyNotify) g_object_unref);
     }


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