Fix possible crash in top bar widget init.

This commit is contained in:
John Preston 2020-07-02 10:10:09 +04:00
parent 370ad0aa44
commit a6c76382e3

View file

@ -536,6 +536,9 @@ void TopBarWidget::updateSearchVisibility() {
} }
void TopBarWidget::updateControlsGeometry() { void TopBarWidget::updateControlsGeometry() {
if (!_activeChat) {
return;
}
auto hasSelected = (_selectedCount > 0); auto hasSelected = (_selectedCount > 0);
auto selectedButtonsTop = countSelectedButtonsTop(_selectedShown.value(hasSelected ? 1. : 0.)); auto selectedButtonsTop = countSelectedButtonsTop(_selectedShown.value(hasSelected ? 1. : 0.));
auto otherButtonsTop = selectedButtonsTop + st::topBarHeight; auto otherButtonsTop = selectedButtonsTop + st::topBarHeight;
@ -615,7 +618,9 @@ void TopBarWidget::setAnimatingMode(bool enabled) {
} }
void TopBarWidget::updateControlsVisibility() { void TopBarWidget::updateControlsVisibility() {
if (_animatingMode) { if (!_activeChat) {
return;
} else if (_animatingMode) {
hideChildren(); hideChildren();
return; return;
} }
@ -660,14 +665,12 @@ void TopBarWidget::updateControlsVisibility() {
void TopBarWidget::updateMembersShowArea() { void TopBarWidget::updateMembersShowArea() {
const auto membersShowAreaNeeded = [&] { const auto membersShowAreaNeeded = [&] {
auto peer = _controller->content()->peer(); const auto peer = _activeChat.peer();
if ((_selectedCount > 0) || !peer) { if ((_selectedCount > 0) || !peer) {
return false; return false;
} } else if (const auto chat = peer->asChat()) {
if (auto chat = peer->asChat()) {
return chat->amIn(); return chat->amIn();
} } else if (const auto megagroup = peer->asMegagroup()) {
if (auto megagroup = peer->asMegagroup()) {
return megagroup->canViewMembers() return megagroup->canViewMembers()
&& (megagroup->membersCount() && (megagroup->membersCount()
< megagroup->session().serverConfig().chatSizeMax); < megagroup->session().serverConfig().chatSizeMax);