Mercurial > pidgin.yaz
changeset 26911:6eb0e3a9c919
Don't leak image refs in gtkstatusbox and assertion failure in nullprpl
purple_imgstore_new_from_file gives us a ref and
pidgin_status_box_set_buddy_icon also takes a ref.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 06 May 2009 18:37:40 +0000 |
parents | 1a1c12c122c9 |
children | 7ff22eb86083 |
files | libpurple/protocols/null/nullprpl.c pidgin/gtkstatusbox.c |
diffstat | 2 files changed, 18 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/null/nullprpl.c Wed May 06 06:40:24 2009 +0000 +++ b/libpurple/protocols/null/nullprpl.c Wed May 06 18:37:40 2009 +0000 @@ -909,7 +909,8 @@ static void nullprpl_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img) { purple_debug_info("nullprpl", "setting %s's buddy icon to %s\n", - gc->account->username, purple_imgstore_get_filename(img)); + gc->account->username, + img ? purple_imgstore_get_filename(img) : "(null)"); } static void nullprpl_remove_group(PurpleConnection *gc, PurpleGroup *group) {
--- a/pidgin/gtkstatusbox.c Wed May 06 06:40:24 2009 +0000 +++ b/pidgin/gtkstatusbox.c Wed May 06 18:37:40 2009 +0000 @@ -471,6 +471,12 @@ img = purple_imgstore_new_from_file(filename); pidgin_status_box_set_buddy_icon(status_box, img); + if (img) + /* + * purple_imgstore_new gives us a reference and + * pidgin_status_box_set_buddy_icon also takes one. + */ + purple_imgstore_unref(img); } status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); @@ -1467,6 +1473,13 @@ if (filename) data = pidgin_convert_buddy_icon(plug, filename, &len); img = purple_buddy_icons_set_account_icon(box->account, data, len); + if (img) + /* + * set_account_icon doesn't give us a reference, but we + * unref one below (for the other code path) + */ + purple_imgstore_ref(img); + purple_account_set_buddy_icon_path(box->account, filename); purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL)); @@ -1486,7 +1499,7 @@ size_t len = 0; if (filename) data = pidgin_convert_buddy_icon(plug, filename, &len); - img = purple_buddy_icons_set_account_icon(account, data, len); + purple_buddy_icons_set_account_icon(account, data, len); purple_account_set_buddy_icon_path(account, filename); } } @@ -1498,6 +1511,8 @@ } pidgin_status_box_set_buddy_icon(box, img); + if (img) + purple_imgstore_unref(img); } static void