From b4d06351f186346bfc65204aa4057641bbde4649 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 4 Mar 2010 13:35:48 +0000 Subject: [PATCH] Cope with the favorite pixbuf not being available Not all icon themes have the favorite icon, so don't rely on it existing (if it's not there, just don't display a bookmark icon) Fixes: #611794 --- libempathy-gtk/empathy-presence-chooser.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c index 7c4aae9b..7e2e89fb 100644 --- a/libempathy-gtk/empathy-presence-chooser.c +++ b/libempathy-gtk/empathy-presence-chooser.c @@ -345,7 +345,7 @@ presence_chooser_set_favorite_icon (EmpathyPresenceChooser *self) GTK_ENTRY_ICON_SECONDARY, _("Click to remove this status as a favorite")); } - else { + else if (priv->not_favorite_pixbuf != NULL) { /* custom entries can be favorited */ gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, @@ -818,6 +818,9 @@ create_not_favorite_pixbuf (void) favorite = empathy_pixbuf_from_icon_name ("emblem-favorite", GTK_ICON_SIZE_MENU); + if (favorite == NULL) + return NULL; + result = gdk_pixbuf_copy (favorite); gdk_pixbuf_saturate_and_pixelate (favorite, result, 1.0, TRUE); @@ -832,7 +835,8 @@ icon_theme_changed_cb (GtkIconTheme *icon_theme, EmpathyPresenceChooserPriv *priv = GET_PRIV (self); /* Theme has changed, recreate the not-favorite icon */ - g_object_unref (priv->not_favorite_pixbuf); + if (priv->not_favorite_pixbuf != NULL) + g_object_unref (priv->not_favorite_pixbuf); priv->not_favorite_pixbuf = create_not_favorite_pixbuf (); /* Update the icon */ @@ -851,7 +855,6 @@ empathy_presence_chooser_init (EmpathyPresenceChooser *chooser) /* Create the not-favorite icon */ priv->not_favorite_pixbuf = create_not_favorite_pixbuf (); - g_assert (priv->not_favorite_pixbuf != NULL); empathy_signal_connect_weak (gtk_icon_theme_get_default (), "changed", G_CALLBACK (icon_theme_changed_cb), @@ -964,7 +967,8 @@ presence_chooser_finalize (GObject *object) g_object_unref (priv->idle); g_object_unref (priv->connectivity); - g_object_unref (priv->not_favorite_pixbuf); + if (priv->not_favorite_pixbuf != NULL) + g_object_unref (priv->not_favorite_pixbuf); G_OBJECT_CLASS (empathy_presence_chooser_parent_class)->finalize (object); } -- 2.39.2