From a6c76382e36c072da3198ac8fc47ffd2a73f2fd5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 2 Jul 2020 10:10:09 +0400 Subject: [PATCH] Fix possible crash in top bar widget init. --- .../history/view/history_view_top_bar_widget.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 0bfbc2b2b9..c08579410a 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -536,6 +536,9 @@ void TopBarWidget::updateSearchVisibility() { } void TopBarWidget::updateControlsGeometry() { + if (!_activeChat) { + return; + } auto hasSelected = (_selectedCount > 0); auto selectedButtonsTop = countSelectedButtonsTop(_selectedShown.value(hasSelected ? 1. : 0.)); auto otherButtonsTop = selectedButtonsTop + st::topBarHeight; @@ -615,7 +618,9 @@ void TopBarWidget::setAnimatingMode(bool enabled) { } void TopBarWidget::updateControlsVisibility() { - if (_animatingMode) { + if (!_activeChat) { + return; + } else if (_animatingMode) { hideChildren(); return; } @@ -660,14 +665,12 @@ void TopBarWidget::updateControlsVisibility() { void TopBarWidget::updateMembersShowArea() { const auto membersShowAreaNeeded = [&] { - auto peer = _controller->content()->peer(); + const auto peer = _activeChat.peer(); if ((_selectedCount > 0) || !peer) { return false; - } - if (auto chat = peer->asChat()) { + } else if (const auto chat = peer->asChat()) { return chat->amIn(); - } - if (auto megagroup = peer->asMegagroup()) { + } else if (const auto megagroup = peer->asMegagroup()) { return megagroup->canViewMembers() && (megagroup->membersCount() < megagroup->session().serverConfig().chatSizeMax);