[gnome-control-center/benzea/fix-criticals-missing-image-loader] avatar-chooser: Return a proper widget if images cannot be loaded




commit df29a26c1e9c59ad265ebdac4b6daecba4b7aaea
Author: Benjamin Berg <bberg redhat com>
Date:   Mon Oct 5 14:56:39 2020 +0200

    avatar-chooser: Return a proper widget if images cannot be loaded
    
    GTK assumes that a widget will be created for a flow box item. So always
    return one instead of falling back to returning NULL. This can primarily
    happen if an image loader is missing.

 panels/user-accounts/cc-avatar-chooser.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/panels/user-accounts/cc-avatar-chooser.c b/panels/user-accounts/cc-avatar-chooser.c
index d0d4e1bbe..c3ea44705 100644
--- a/panels/user-accounts/cc-avatar-chooser.c
+++ b/panels/user-accounts/cc-avatar-chooser.c
@@ -366,8 +366,16 @@ create_face_widget (gpointer item,
                                                           AVATAR_CHOOSER_PIXEL_SIZE,
                                                           AVATAR_CHOOSER_PIXEL_SIZE,
                                                           NULL);
-        if (source_pixbuf == NULL)
-                return NULL;
+        if (source_pixbuf == NULL) {
+                image = gtk_image_new_from_icon_name ("image-missing", GTK_ICON_SIZE_DIALOG);
+                gtk_image_set_pixel_size (GTK_IMAGE (image), AVATAR_CHOOSER_PIXEL_SIZE);
+                gtk_widget_show (image);
+
+                g_object_set_data_full (G_OBJECT (image),
+                                        "filename", g_steal_pointer (&image_path), g_free);
+
+                return image;
+        }
 
         pixbuf = round_image (source_pixbuf);
         image = gtk_image_new_from_pixbuf (pixbuf);


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