From f9cb9a2b057b2ebc2e1f5cbf479e56595c0fdfb8 Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Tue, 30 Apr 2024 12:58:07 -0700 Subject: Can't delete from a map while iterating over it. --- indra/newview/llvoicewebrtc.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 2bd6eee84d..0823358e03 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -1230,16 +1230,19 @@ void LLWebRTCVoiceClient::sessionState::removeParticipant(const LLWebRTCVoiceCli void LLWebRTCVoiceClient::sessionState::removeAllParticipants(const LLUUID ®ion) { - LL_DEBUGS("Voice") << "called" << LL_ENDL; - + std::vector 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. -- cgit v1.2.3