Can't delete from a map while iterating over it.

master
Roxie Linden 2024-04-30 12:58:07 -07:00
parent 2c50399720
commit f9cb9a2b05
1 changed files with 8 additions and 5 deletions

View File

@ -1230,16 +1230,19 @@ void LLWebRTCVoiceClient::sessionState::removeParticipant(const LLWebRTCVoiceCli
void LLWebRTCVoiceClient::sessionState::removeAllParticipants(const LLUUID &region)
{
LL_DEBUGS("Voice") << "called" << LL_ENDL;
std::vector<participantStatePtr_t> participantsToRemove;
for (auto &&participant : mParticipantsByUUID)
for (auto& participantEntry : mParticipantsByUUID)
{
if (region.isNull() || (participant.second->mRegion == region))
if (region.isNull() || (participantEntry.second->mRegion == region))
{
removeParticipant(participant.second);
participantsToRemove.push_back(participantEntry.second);
}
}
for (auto& participant : participantsToRemove)
{
removeParticipant(participant);
}
}
// Initiated the various types of sessions.