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
This commit is contained in:
Jehan 2019-10-12 11:59:53 +02:00
parent 1046430df1
commit 9dcdf37ab3
1 changed files with 10 additions and 2 deletions

View File

@ -589,7 +589,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);
}
/**
@ -1313,8 +1313,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);
}