Skip to content

Commit bdd199e

Browse files
committed
copy and clear
1 parent 874593c commit bdd199e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/src/core/room.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -525,15 +525,14 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
525525
_serverVersion = null;
526526
_serverRegion = null;
527527

528+
final participants = _remoteParticipants.toList();
529+
_remoteParticipants.clear();
528530
_activeSpeakers.clear();
529-
530-
// Clean up RemoteParticipants
531-
for (final participant in _remoteParticipants) {
531+
for (final participant in participants) {
532532
events.emit(ParticipantDisconnectedEvent(participant: participant));
533533
await participant.removeAllPublishedTracks(notify: false);
534534
await participant.dispose();
535535
}
536-
_remoteParticipants.clear();
537536

538537
notifyListeners();
539538
})
@@ -965,12 +964,13 @@ extension RoomPrivateMethods on Room {
965964
logger.fine('[${objectId}] cleanUp()');
966965

967966
// clean up RemoteParticipants
968-
for (final participant in _remoteParticipants) {
967+
final participants = _remoteParticipants.toList();
968+
_remoteParticipants.clear();
969+
for (final participant in participants) {
969970
await participant.removeAllPublishedTracks(notify: false);
970971
// RemoteParticipant is responsible for disposing resources
971972
await participant.dispose();
972973
}
973-
_remoteParticipants.clear();
974974
_pendingTrackQueue.clear();
975975

976976
// clean up LocalParticipant

0 commit comments

Comments
 (0)