# HG changeset patch # User Paul Aurich # Date 1241592024 0 # Node ID 1a1c12c122c9188700aaa0166333bf3e85eb7cc9 # Parent 839c5481b32a6a6409de5b04e1851511aab59b61 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. diff -r 839c5481b32a -r 1a1c12c122c9 libpurple/buddyicon.c --- 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) { diff -r 839c5481b32a -r 1a1c12c122c9 pidgin/gtkstatusbox.c --- 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);