# HG changeset patch # User Mark Doliner # Date 1155712781 0 # Node ID 92f5e6f3acfb9dd9854b96da3808de6afffe855f # Parent 11394a70de3756dbf5e203b30ee514cec25a0c4a [gaim-migrate @ 16786] More/better assertion fixes. Especially when starting Gaim with an account that doesn't have the global buddy icon preference set, or when trying to set an icon using a file that is not an image. committer: Tailor Script diff -r 11394a70de37 -r 92f5e6f3acfb src/gtkstatusbox.c --- a/src/gtkstatusbox.c Wed Aug 16 07:02:26 2006 +0000 +++ b/src/gtkstatusbox.c Wed Aug 16 07:19:41 2006 +0000 @@ -1179,16 +1179,19 @@ icon_alc.x = allocation->width - icon_alc.width; icon_alc.y += 3; - if ((status_box->buddy_icon_path != NULL) && - (status_box->icon_size != icon_alc.height)) + if (status_box->icon_size != icon_alc.height) { - scaled = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, - icon_alc.height, icon_alc.width, FALSE, NULL); - status_box->buddy_icon_hover = gdk_pixbuf_copy(scaled); - do_colorshift(status_box->buddy_icon_hover, status_box->buddy_icon_hover, 30); - g_object_unref(status_box->buddy_icon); - status_box->buddy_icon = scaled; - gtk_image_set_from_pixbuf(GTK_IMAGE(status_box->icon), status_box->buddy_icon); + if ((status_box->buddy_icon_path != NULL) && + (*status_box->buddy_icon_path != '\0')) + { + scaled = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, + icon_alc.height, icon_alc.width, FALSE, NULL); + status_box->buddy_icon_hover = gdk_pixbuf_copy(scaled); + do_colorshift(status_box->buddy_icon_hover, status_box->buddy_icon_hover, 30); + g_object_unref(status_box->buddy_icon); + status_box->buddy_icon = scaled; + gtk_image_set_from_pixbuf(GTK_IMAGE(status_box->icon), status_box->buddy_icon); + } status_box->icon_size = icon_alc.height; } gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->icon_box, &icon_alc); @@ -1337,15 +1340,19 @@ g_free(box->buddy_icon_path); box->buddy_icon_path = g_strdup(filename); - if (filename != NULL) + if ((filename != NULL) && (*filename != '\0')) { + if (box->buddy_icon != NULL) + g_object_unref(box->buddy_icon); scaled = gdk_pixbuf_new_from_file_at_scale(filename, box->icon_size, box->icon_size, FALSE, NULL); - box->buddy_icon_hover = gdk_pixbuf_copy(scaled); - do_colorshift(box->buddy_icon_hover, box->buddy_icon_hover, 30); - g_object_unref(box->buddy_icon); - box->buddy_icon = scaled; - gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon); + if (scaled != NULL) + { + box->buddy_icon_hover = gdk_pixbuf_copy(scaled); + do_colorshift(box->buddy_icon_hover, box->buddy_icon_hover, 30); + box->buddy_icon = scaled; + gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon); + } } gaim_prefs_set_string("/gaim/gtk/accounts/buddyicon", filename); diff -r 11394a70de37 -r 92f5e6f3acfb src/gtkutils.c --- a/src/gtkutils.c Wed Aug 16 07:02:26 2006 +0000 +++ b/src/gtkutils.c Wed Aug 16 07:19:41 2006 +0000 @@ -2453,7 +2453,7 @@ } #endif -char* +char * gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path) { #if GTK_CHECK_VERSION(2,2,0) @@ -2518,6 +2518,8 @@ format = gdk_pixbuf_loader_get_format(loader); g_object_unref(G_OBJECT(loader)); #endif + if (format == NULL) + return NULL; pixbuf_formats = gdk_pixbuf_format_get_extensions(format); if (str_array_match(pixbuf_formats, prpl_formats) && /* This is an acceptable format AND */