Mercurial > pidgin.yaz
changeset 16376:dd47fa8ba3e4
Bug fixes! From my preliminary testing, the standard buddy icon stuff is working.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 24 Apr 2007 04:35:38 +0000 |
parents | 391a79778f89 |
children | 44489a2123e7 |
files | libpurple/buddyicon.c libpurple/imgstore.c |
diffstat | 2 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/buddyicon.c Tue Apr 24 03:57:07 2007 +0000 +++ b/libpurple/buddyicon.c Tue Apr 24 04:35:38 2007 +0000 @@ -62,6 +62,7 @@ g_return_if_fail(filename != NULL); refs = GPOINTER_TO_INT(g_hash_table_lookup(icon_file_cache, filename)); + printf("refs before increment = %d\n", refs); g_hash_table_insert(icon_file_cache, g_strdup(filename), GINT_TO_POINTER(refs + 1)); @@ -76,6 +77,7 @@ return; refs = GPOINTER_TO_INT(g_hash_table_lookup(icon_file_cache, filename)); + printf("refs before decrement = %d\n", refs); if (refs == 1) { @@ -174,21 +176,28 @@ /* It's possible that there are other references to this icon * cache file that are not currently loaded into memory. */ - if (g_hash_table_lookup(icon_file_cache, filename)) + printf("file has %d refs\n", GPOINTER_TO_INT(g_hash_table_lookup(icon_file_cache, filename))); + if (GPOINTER_TO_INT(g_hash_table_lookup(icon_file_cache, filename))) return; dirname = purple_buddy_icons_get_cache_dir(); path = g_build_filename(dirname, filename, NULL); + printf("Going to unlink %s\n", path); if (g_file_test(path, G_FILE_TEST_EXISTS)) { if (g_unlink(path)) { + printf("Failed to unlink %s\n", path); + purple_debug_error("buddyicon", "Failed to delete %s: %s\n", path, strerror(errno)); } else + { + printf("Unlinked %s\n", path); purple_debug_info("buddyicon", "Deleted cache file: %s\n", path); + } } g_free(path); @@ -279,6 +288,8 @@ g_return_val_if_fail(icon_data != NULL, NULL); g_return_val_if_fail(icon_len > 0, NULL); + /* purple_buddy_icons_find() does allocation, so be + * sure to update it as well when members are added. */ icon = purple_buddy_icons_find(account, username); /* purple_buddy_icon_create() sets account & username */ @@ -288,7 +299,9 @@ /* Take a reference for the caller of this function. */ icon->ref_count = 1; - /* purple_buddy_icon_set_data() sets img */ + /* purple_buddy_icon_set_data() sets img, but it + * references img first, so we need to initialize it */ + icon->img = NULL; purple_buddy_icon_set_data(icon, icon_data, icon_len); return icon; @@ -372,12 +385,14 @@ purple_blist_node_set_string((PurpleBlistNode *)buddy, "buddy_icon", filename); + printf("Calling ref_filename(%s)\n", filename); ref_filename(filename); } else { purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon"); } + printf("Calling unref_filename(%s)\n", old_icon); unref_filename(old_icon); g_free(old_icon); } @@ -403,8 +418,10 @@ if (data != NULL && len > 0) icon->img = purple_buddy_icon_data_new(data, len, NULL); + printf("Calling purple_buddy_icon_update\n"); purple_buddy_icon_update(icon); + printf("Calling purple_imgstore_unref\n"); purple_imgstore_unref(old_img); } @@ -456,7 +473,7 @@ g_return_if_fail(account != NULL); g_return_if_fail(username != NULL); - if (icon_data == NULL || icon_len == 0) + if (icon_data != NULL && icon_len > 0) { PurpleBuddyIcon *icon; @@ -547,6 +564,8 @@ { if (icon == NULL) icon = purple_buddy_icon_create(account, username); + icon->ref_count = 0; + icon->img = NULL; purple_buddy_icon_set_data(icon, data, len); } g_free(path);