pidgin: 0cb6e54b: Look up the old image before we store th...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Wed May 6 02:45:28 EDT 2009


-----------------------------------------------------------------
Revision: 0cb6e54b872e187a678895961106518e55aab987
Ancestor: 63eed8332804fcd21df43cd1d222794c6018b79f
Author: darkrain42 at pidgin.im
Date: 2009-05-06T06:40:24
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/0cb6e54b872e187a678895961106518e55aab987

Modified files:
        libpurple/buddyicon.c pidgin/gtkstatusbox.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- libpurple/buddyicon.c	f0509debca62b7316fff43aab3b3ae0fdec06a06
+++ libpurple/buddyicon.c	9a9f3a332ca776b152c1cd7e74f45cb07bac2917
@@ -753,6 +753,8 @@ purple_buddy_icons_set_account_icon(Purp
 	}
 	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 @@ purple_buddy_icons_set_account_icon(Purp
 			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)
 	{
============================================================
--- pidgin/gtkstatusbox.c	67c9937e696c80e1da2c94b5121692abdab61a77
+++ pidgin/gtkstatusbox.c	279ea5caf9388ea4dc8d959fc3149c95afd55ccb
@@ -468,14 +468,7 @@ setup_icon_box(PidginStatusBox *status_b
 		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 @@ buddy_icon_set_cb(const char *filename, 
 
 		/* 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);


More information about the Commits mailing list