From 64243d14372eef494c2b7f21240a00ffa0f6eb3f Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 14 May 2021 20:25:45 +0400 Subject: [PATCH] Fix crash in joining active video chat. --- .../calls/group/calls_group_panel.cpp | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index e356dc54d7..e2f9b6c025 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -1243,15 +1243,26 @@ void Panel::setupPinnedVideo() { } _call->videoStreamActiveUpdates( ) | rpl::start_with_next([=](const VideoEndpoint &endpoint) { - const auto &tracks = _call->activeVideoTracks(); - const auto i = tracks.find(endpoint); - if (i != end(tracks)) { - _videoTiles.push_back(setupTile(endpoint, i->second)); + if (_call->activeVideoTracks().contains(endpoint)) { + // Add async (=> the participant row is definitely in Members). + crl::on_main(_pinnedVideoWrap.get(), [=] { + const auto &tracks = _call->activeVideoTracks(); + const auto i = tracks.find(endpoint); + if (i != end(tracks)) { + _videoTiles.push_back(setupTile(endpoint, i->second)); + } + }); } else { - _videoTiles.erase( - ranges::remove(_videoTiles, endpoint, &VideoTile::endpoint), - end(_videoTiles)); - refreshTilesGeometry(); + // Remove sync. + const auto eraseTill = end(_videoTiles); + const auto eraseFrom = ranges::remove( + _videoTiles, + endpoint, + &VideoTile::endpoint); + if (eraseFrom != eraseTill) { + _videoTiles.erase(eraseFrom, eraseTill); + refreshTilesGeometry(); + } } }, _pinnedVideoWrap->lifetime());