diff --git a/src/groupchat.c b/src/groupchat.c index d149aa2..eb1a078 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -114,6 +114,7 @@ static const char group_cmd_list[AC_NUM_GROUP_COMMANDS][MAX_CMDNAME_SIZE] = { static void groupchat_set_group_name(ToxWindow *self, Tox *m, int groupnum); ToxWindow new_group_chat(Tox *m, int groupnum, const char *groupname, int length); +static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnum); int init_groupchat_win(Tox *m, int groupnum, const char *groupname, int length) { @@ -139,12 +140,13 @@ int init_groupchat_win(Tox *m, int groupnum, const char *groupname, int length) if (groupchats[i].peer_names == NULL || groupchats[i].peer_name_lengths == NULL) exit_toxic_err("failed in init_groupchat_win", FATALERR_MEMORY); - set_active_window(groupchats[i].chatwin); - if (i == max_groupchat_index) ++max_groupchat_index; + set_active_window(groupchats[i].chatwin); + groupchat_onGroupNamelistChange(&self, m, groupnum); store_data(m, DATA_FILE); + return 0; } } @@ -436,6 +438,9 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu int num_peers = tox_group_get_number_peers(m, groupnum); + if (num_peers <= 0) + return; + uint8_t tmp_peerlist[num_peers][TOX_MAX_NAME_LENGTH]; uint16_t tmp_peerlens[num_peers]; diff --git a/src/toxic.c b/src/toxic.c index f6c5284..cadb64a 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -712,10 +712,11 @@ static Tox *load_toxic(char *data_path) queue_init_message("Falling back to ipv4"); tox_opts.ipv6_enabled = false; m = load_tox(data_path, &tox_opts, &new_err); - } else if (new_err != TOX_ERR_NEW_OK) { - exit_toxic_err("Tox network failed to initialize (tox_new failed with error %d)", new_err); } + if (new_err != TOX_ERR_NEW_OK) + exit_toxic_err("Tox network failed to initialize (tox_new failed with error %d)", new_err); + init_tox_callbacks(m); load_friendlist(m); load_blocklist(BLOCK_FILE);