changeset 26821:1a1c12c122c9

Look up the old image before we store the new one in the hash table. Looking up the new image and then unref:ing it (hence freeing the data and subsequently returning it) is not good. This was causing problems with changing buddy icons while using mystatusbox. Closes #9120.
author Paul Aurich <paul@darkrain42.org>
date Wed, 06 May 2009 06:40:24 +0000
parents 839c5481b32a
children 885320258863 6eb0e3a9c919 6028712210ca
files libpurple/buddyicon.c pidgin/gtkstatusbox.c
diffstat 2 files changed, 5 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/buddyicon.c	Mon May 04 15:47:54 2009 +0000
+++ b/libpurple/buddyicon.c	Wed May 06 06:40:24 2009 +0000
@@ -753,6 +753,8 @@
 	}
 	unref_filename(old_icon);
 
+	old_img = g_hash_table_lookup(pointer_icon_cache, account);
+
 	if (img)
 		g_hash_table_insert(pointer_icon_cache, account, img);
 	else
@@ -770,7 +772,7 @@
 			prpl_info->set_buddy_icon(gc, img);
 	}
 
-	if ((old_img = g_hash_table_lookup(pointer_icon_cache, account)))
+	if (old_img)
 		purple_imgstore_unref(old_img);
 	else if (old_icon)
 	{
--- a/pidgin/gtkstatusbox.c	Mon May 04 15:47:54 2009 +0000
+++ b/pidgin/gtkstatusbox.c	Wed May 06 06:40:24 2009 +0000
@@ -468,14 +468,7 @@
 		PurpleStoredImage *img = NULL;
 
 		if (filename != NULL)
-		{
-			gchar *contents;
-			gsize size;
-			if (g_file_get_contents(filename, &contents, &size, NULL))
-			{
-				img = purple_imgstore_add(contents, size, filename);
-			}
-		}
+			img = purple_imgstore_new_from_file(filename);
 
 		pidgin_status_box_set_buddy_icon(status_box, img);
 	}
@@ -1501,14 +1494,7 @@
 
 		/* Even if no accounts were processed, load the icon that was set. */
 		if (filename != NULL)
-		{
-			gchar *contents;
-			gsize size;
-			if (g_file_get_contents(filename, &contents, &size, NULL))
-			{
-				img = purple_imgstore_add(contents, size, filename);
-			}
-		}
+			img = purple_imgstore_new_from_file(filename);
 	}
 
 	pidgin_status_box_set_buddy_icon(box, img);