Mercurial > pidgin
comparison libpurple/conversation.c @ 31712:f7c3aac5b22b
conversation: Use a copy of the name and clear hash after emitting "left" signals
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Tue, 21 Jun 2011 03:34:50 +0000 |
parents | 4dabe4bdfb29 |
children | 298685661f89 |
comparison
equal
deleted
inserted
replaced
31711:84ac2406bb10 | 31712:f7c3aac5b22b |
---|---|
411 const char *disp; | 411 const char *disp; |
412 | 412 |
413 conv->u.chat = g_new0(PurpleConvChat, 1); | 413 conv->u.chat = g_new0(PurpleConvChat, 1); |
414 conv->u.chat->conv = conv; | 414 conv->u.chat->conv = conv; |
415 conv->u.chat->users = g_hash_table_new_full(_purple_conversation_user_hash, | 415 conv->u.chat->users = g_hash_table_new_full(_purple_conversation_user_hash, |
416 _purple_conversation_user_equal, NULL, NULL); | 416 _purple_conversation_user_equal, g_free, NULL); |
417 PURPLE_DBUS_REGISTER_POINTER(conv->u.chat, PurpleConvChat); | 417 PURPLE_DBUS_REGISTER_POINTER(conv->u.chat, PurpleConvChat); |
418 | 418 |
419 chats = g_list_prepend(chats, conv); | 419 chats = g_list_prepend(chats, conv); |
420 | 420 |
421 if ((disp = purple_connection_get_display_name(account->gc))) | 421 if ((disp = purple_connection_get_display_name(account->gc))) |
1700 | 1700 |
1701 cbuddy = purple_conv_chat_cb_new(user, alias, flag); | 1701 cbuddy = purple_conv_chat_cb_new(user, alias, flag); |
1702 cbuddy->buddy = purple_find_buddy(conv->account, user) != NULL; | 1702 cbuddy->buddy = purple_find_buddy(conv->account, user) != NULL; |
1703 | 1703 |
1704 chat->in_room = g_list_prepend(chat->in_room, cbuddy); | 1704 chat->in_room = g_list_prepend(chat->in_room, cbuddy); |
1705 g_hash_table_replace(chat->users, cbuddy->name, cbuddy); | 1705 g_hash_table_replace(chat->users, g_strdup(cbuddy->name), cbuddy); |
1706 | 1706 |
1707 cbuddies = g_list_prepend(cbuddies, cbuddy); | 1707 cbuddies = g_list_prepend(cbuddies, cbuddy); |
1708 | 1708 |
1709 if (!quiet && new_arrivals) { | 1709 if (!quiet && new_arrivals) { |
1710 char *alias_esc = g_markup_escape_text(alias, -1); | 1710 char *alias_esc = g_markup_escape_text(alias, -1); |
1794 flags = purple_conv_chat_user_get_flags(chat, old_user); | 1794 flags = purple_conv_chat_user_get_flags(chat, old_user); |
1795 cb = purple_conv_chat_cb_new(new_user, new_alias, flags); | 1795 cb = purple_conv_chat_cb_new(new_user, new_alias, flags); |
1796 cb->buddy = purple_find_buddy(conv->account, new_user) != NULL; | 1796 cb->buddy = purple_find_buddy(conv->account, new_user) != NULL; |
1797 | 1797 |
1798 chat->in_room = g_list_prepend(chat->in_room, cb); | 1798 chat->in_room = g_list_prepend(chat->in_room, cb); |
1799 g_hash_table_replace(chat->users, cb->name, cb); | 1799 g_hash_table_replace(chat->users, g_strdup(cb->name), cb); |
1800 | 1800 |
1801 if (ops != NULL && ops->chat_rename_user != NULL) | 1801 if (ops != NULL && ops->chat_rename_user != NULL) |
1802 ops->chat_rename_user(conv, old_user, new_user, new_alias); | 1802 ops->chat_rename_user(conv, old_user, new_user, new_alias); |
1803 | 1803 |
1804 cb = purple_conv_chat_cb_find(chat, old_user); | 1804 cb = purple_conv_chat_cb_find(chat, old_user); |
1965 } | 1965 } |
1966 ops->chat_remove_users(conv, names); | 1966 ops->chat_remove_users(conv, names); |
1967 g_list_free(names); | 1967 g_list_free(names); |
1968 } | 1968 } |
1969 | 1969 |
1970 g_hash_table_remove_all(chat->users); | |
1971 | |
1972 for (l = users; l; l = l->next) | 1970 for (l = users; l; l = l->next) |
1973 { | 1971 { |
1974 PurpleConvChatBuddy *cb = l->data; | 1972 PurpleConvChatBuddy *cb = l->data; |
1975 | 1973 |
1976 purple_signal_emit(purple_conversations_get_handle(), | 1974 purple_signal_emit(purple_conversations_get_handle(), |
1978 purple_signal_emit(purple_conversations_get_handle(), | 1976 purple_signal_emit(purple_conversations_get_handle(), |
1979 "chat-buddy-left", conv, cb->name, NULL); | 1977 "chat-buddy-left", conv, cb->name, NULL); |
1980 | 1978 |
1981 purple_conv_chat_cb_destroy(cb); | 1979 purple_conv_chat_cb_destroy(cb); |
1982 } | 1980 } |
1981 | |
1982 g_hash_table_remove_all(chat->users); | |
1983 chat->users = NULL; | |
1983 | 1984 |
1984 g_list_free(users); | 1985 g_list_free(users); |
1985 chat->in_room = NULL; | 1986 chat->in_room = NULL; |
1986 } | 1987 } |
1987 | 1988 |