[gnome-initial-setup] account: Fix a critical warning if loading an avatar from a path fails
- From: Will Thompson <wjt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] account: Fix a critical warning if loading an avatar from a path fails
- Date: Tue, 11 Feb 2020 14:01:23 +0000 (UTC)
commit 09e6b51e49997fc874ecfba4883d822696ddc1cf
Author: Philip Withnall <withnall endlessm com>
Date: Thu Feb 6 13:37:52 2020 +0000
account: Fix a critical warning if loading an avatar from a path fails
If it fails, `pixbuf` is `NULL`, which then caused critical warnings
further down the function. Fix that, and use `g_autoptr()` to simplify
the memory management.
Signed-off-by: Philip Withnall <withnall endlessm com>
gnome-initial-setup/pages/account/um-photo-dialog.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/gnome-initial-setup/pages/account/um-photo-dialog.c
b/gnome-initial-setup/pages/account/um-photo-dialog.c
index b61c2aa..f85f054 100644
--- a/gnome-initial-setup/pages/account/um-photo-dialog.c
+++ b/gnome-initial-setup/pages/account/um-photo-dialog.c
@@ -190,7 +190,7 @@ static GtkWidget *
create_face_widget (gpointer item,
gpointer user_data)
{
- GdkPixbuf *pixbuf = NULL;
+ g_autoptr(GdkPixbuf) pixbuf = NULL;
GtkWidget *image;
g_autofree gchar *path = g_file_get_path (G_FILE (item));
@@ -198,11 +198,12 @@ create_face_widget (gpointer item,
AVATAR_PIXEL_SIZE,
AVATAR_PIXEL_SIZE,
NULL);
- if (pixbuf == NULL)
- return NULL;
- image = gtk_image_new_from_pixbuf (round_image (pixbuf));
- g_object_unref (pixbuf);
+ if (pixbuf != NULL)
+ image = gtk_image_new_from_pixbuf (round_image (pixbuf));
+ else
+ image = gtk_image_new ();
+
gtk_image_set_pixel_size (GTK_IMAGE (image), AVATAR_PIXEL_SIZE);
gtk_widget_show (image);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]