Mercurial > pidgin.yaz
comparison src/buddyicon.c @ 9323:59bca4e8678c
[gaim-migrate @ 10131]
This should help make buddy icons get destroyed right and stuff.
Except the UI doesn't seem to care. I'll work on that.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Sun, 20 Jun 2004 05:39:21 +0000 |
parents | 0c201a2386c7 |
children | ef8e4740254d |
comparison
equal
deleted
inserted
replaced
9322:119f8a2c00b6 | 9323:59bca4e8678c |
---|---|
67 (char *)gaim_buddy_icon_get_username(icon), icon); | 67 (char *)gaim_buddy_icon_get_username(icon), icon); |
68 } | 68 } |
69 | 69 |
70 gaim_buddy_icon_set_data(icon, icon_data, icon_len); | 70 gaim_buddy_icon_set_data(icon, icon_data, icon_len); |
71 | 71 |
72 gaim_buddy_icon_ref(icon); | 72 /* We don't take a reference here. In fact we may want to check if we have |
73 | 73 * a reference (gaim_buddy_icon_set_data should have added one or more) |
74 * and destroy ourselves if we don't. | |
75 */ | |
74 return icon; | 76 return icon; |
75 } | 77 } |
76 | 78 |
77 void | 79 void |
78 gaim_buddy_icon_destroy(GaimBuddyIcon *icon) | 80 gaim_buddy_icon_destroy(GaimBuddyIcon *icon) |
85 | 87 |
86 g_return_if_fail(icon != NULL); | 88 g_return_if_fail(icon != NULL); |
87 | 89 |
88 if (icon->ref_count > 0) | 90 if (icon->ref_count > 0) |
89 { | 91 { |
90 gaim_buddy_icon_unref(icon); | 92 /* If the ref count is greater than 0, then we weren't called from |
93 * gaim_buddy_icon_unref(). So we go through and ask everyone to | |
94 * unref us. Then we return, since we know somewhere along the | |
95 * line we got called recursively by one of the unrefs, and the | |
96 * icon is already destroyed. | |
97 */ | |
98 account = gaim_buddy_icon_get_account(icon); | |
99 username = gaim_buddy_icon_get_username(icon); | |
100 | |
101 conv = gaim_find_conversation_with_account(username, account); | |
102 if (conv != NULL && gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
103 gaim_conv_im_set_icon(GAIM_CONV_IM(conv), NULL); | |
104 | |
105 for (list = sl = gaim_find_buddies(account, username); sl != NULL; | |
106 sl = sl->next) | |
107 { | |
108 GaimBuddy *buddy = (GaimBuddy *)sl->data; | |
109 | |
110 gaim_buddy_set_icon(buddy, NULL); | |
111 } | |
112 | |
113 g_slist_free(list); | |
91 | 114 |
92 return; | 115 return; |
93 } | 116 } |
94 | |
95 account = gaim_buddy_icon_get_account(icon); | |
96 username = gaim_buddy_icon_get_username(icon); | |
97 | |
98 conv = gaim_find_conversation_with_account(username, account); | |
99 | |
100 for (list = sl = gaim_find_buddies(account, username); sl != NULL; | |
101 sl = sl->next) | |
102 { | |
103 GaimBuddy *buddy = (GaimBuddy *)sl->data; | |
104 | |
105 gaim_buddy_set_icon(buddy, NULL); | |
106 } | |
107 | |
108 g_slist_free(list); | |
109 | |
110 if (conv != NULL && gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
111 gaim_conv_im_set_icon(GAIM_CONV_IM(conv), NULL); | |
112 | 117 |
113 icon_cache = g_hash_table_lookup(account_cache, | 118 icon_cache = g_hash_table_lookup(account_cache, |
114 gaim_buddy_icon_get_account(icon)); | 119 gaim_buddy_icon_get_account(icon)); |
115 | 120 |
116 if (icon_cache != NULL) | 121 if (icon_cache != NULL) |