Browse Source

fix(groups): Fix invalid group list on group member join

The call to Core::getGroupPeerNames is expected to return a list where
the index in the list is the group member id. In any error case we were
previously breaking this constraint. It turns out that every time
someone joins a group we call this function before they have a valid
name resulting in their id not being added to the list.

This fix ensures that the list coming out of Core::getGroupPeerNames
always has a full list.

Fixes #5838
reviewable/pr5919/r1
Mick Sayson 6 years ago
parent
commit
fd243738c1
  1. 6
      src/core/core.cpp

6
src/core/core.cpp

@ -1502,7 +1502,9 @@ QStringList Core::getGroupPeerNames(int groupId) const @@ -1502,7 +1502,9 @@ QStringList Core::getGroupPeerNames(int groupId) const
for (uint32_t i = 0; i < nPeers; ++i) {
Tox_Err_Conference_Peer_Query error;
size_t length = tox_conference_peer_get_name_size(tox.get(), groupId, i, &error);
if (!PARSE_ERR(error) || !length) {
names.append(QString());
continue;
}
@ -1510,9 +1512,13 @@ QStringList Core::getGroupPeerNames(int groupId) const @@ -1510,9 +1512,13 @@ QStringList Core::getGroupPeerNames(int groupId) const
tox_conference_peer_get_name(tox.get(), groupId, i, nameBuf.data(), &error);
if (PARSE_ERR(error)) {
names.append(ToxString(nameBuf.data(), length).getQString());
} else {
names.append(QString());
}
}
assert(names.size() == nPeers);
return names;
}

Loading…
Cancel
Save