From: <the...@us...> - 2006-08-16 07:19:46
|
Revision: 16786 Author: thekingant Date: 2006-08-16 00:19:41 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16786&view=rev Log Message: ----------- 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. Modified Paths: -------------- trunk/src/gtkstatusbox.c trunk/src/gtkutils.c Modified: trunk/src/gtkstatusbox.c =================================================================== --- trunk/src/gtkstatusbox.c 2006-08-16 07:02:26 UTC (rev 16785) +++ trunk/src/gtkstatusbox.c 2006-08-16 07:19:41 UTC (rev 16786) @@ -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); Modified: trunk/src/gtkutils.c =================================================================== --- trunk/src/gtkutils.c 2006-08-16 07:02:26 UTC (rev 16785) +++ trunk/src/gtkutils.c 2006-08-16 07:19:41 UTC (rev 16786) @@ -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 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |