Added some safeguards against crashes.
This commit is contained in:
parent
e6aea86754
commit
17c166cc41
@ -332,7 +332,7 @@ twc_group_namelist_change_callback(Tox *tox,
|
|||||||
group_number,
|
group_number,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
struct t_gui_nick *nick;
|
struct t_gui_nick *nick = NULL;
|
||||||
char *name = twc_get_peer_name_nt(profile->tox, group_number, peer_number);
|
char *name = twc_get_peer_name_nt(profile->tox, group_number, peer_number);
|
||||||
char *prev_name = NULL;
|
char *prev_name = NULL;
|
||||||
|
|
||||||
@ -340,10 +340,13 @@ twc_group_namelist_change_callback(Tox *tox,
|
|||||||
|| change_type == TOX_CHAT_CHANGE_PEER_NAME)
|
|| change_type == TOX_CHAT_CHANGE_PEER_NAME)
|
||||||
{
|
{
|
||||||
nick = weechat_hashtable_get(chat->nicks, &peer_number);
|
nick = weechat_hashtable_get(chat->nicks, &peer_number);
|
||||||
prev_name = strdup(weechat_nicklist_nick_get_string(chat->buffer,
|
if (nick)
|
||||||
nick, "name"));
|
{
|
||||||
weechat_nicklist_remove_nick(chat->buffer, nick);
|
prev_name = strdup(weechat_nicklist_nick_get_string(chat->buffer,
|
||||||
weechat_hashtable_remove(chat->nicks, &peer_number);
|
nick, "name"));
|
||||||
|
weechat_nicklist_remove_nick(chat->buffer, nick);
|
||||||
|
weechat_hashtable_remove(chat->nicks, &peer_number);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change_type == TOX_CHAT_CHANGE_PEER_ADD
|
if (change_type == TOX_CHAT_CHANGE_PEER_ADD
|
||||||
@ -351,22 +354,26 @@ twc_group_namelist_change_callback(Tox *tox,
|
|||||||
{
|
{
|
||||||
nick = weechat_nicklist_add_nick(chat->buffer, chat->nicklist_group,
|
nick = weechat_nicklist_add_nick(chat->buffer, chat->nicklist_group,
|
||||||
name, NULL, NULL, NULL, 1);
|
name, NULL, NULL, NULL, 1);
|
||||||
weechat_hashtable_set(chat->nicks, &peer_number, nick);
|
if (nick)
|
||||||
|
weechat_hashtable_set(chat->nicks, &peer_number, nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (change_type)
|
switch (change_type)
|
||||||
{
|
{
|
||||||
case TOX_CHAT_CHANGE_PEER_NAME:
|
case TOX_CHAT_CHANGE_PEER_NAME:
|
||||||
weechat_printf(chat->buffer, "%s%s is now known as %s",
|
if (prev_name && name)
|
||||||
weechat_prefix("network"), prev_name, name);
|
weechat_printf(chat->buffer, "%s%s is now known as %s",
|
||||||
|
weechat_prefix("network"), prev_name, name);
|
||||||
break;
|
break;
|
||||||
case TOX_CHAT_CHANGE_PEER_ADD:
|
case TOX_CHAT_CHANGE_PEER_ADD:
|
||||||
weechat_printf(chat->buffer, "%s%s just joined the group chat",
|
if (name)
|
||||||
weechat_prefix("join"), name);
|
weechat_printf(chat->buffer, "%s%s just joined the group chat",
|
||||||
|
weechat_prefix("join"), name);
|
||||||
break;
|
break;
|
||||||
case TOX_CHAT_CHANGE_PEER_DEL:
|
case TOX_CHAT_CHANGE_PEER_DEL:
|
||||||
weechat_printf(chat->buffer, "%s%s just left the group chat",
|
if (prev_name)
|
||||||
weechat_prefix("quit"), prev_name);
|
weechat_printf(chat->buffer, "%s%s just left the group chat",
|
||||||
|
weechat_prefix("quit"), prev_name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user