From bc7139d67af4377ea5432dfbd4374ad87cfe1c99 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 14 Apr 2017 15:12:40 +0300 Subject: [PATCH] Fix crash in AuthSession::Exists() if there is no Messenger. Also use toggleAnimated instead of show/hideAnimated in intro. --- Telegram/SourceFiles/auth_session.cpp | 5 ++++- Telegram/SourceFiles/intro/introwidget.cpp | 20 ++++++-------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Telegram/SourceFiles/auth_session.cpp b/Telegram/SourceFiles/auth_session.cpp index f3b614b8c7..70d5a84bf6 100644 --- a/Telegram/SourceFiles/auth_session.cpp +++ b/Telegram/SourceFiles/auth_session.cpp @@ -93,7 +93,10 @@ AuthSession::AuthSession(UserId userId) } bool AuthSession::Exists() { - return (Messenger::Instance().authSession() != nullptr); + if (auto messenger = Messenger::InstancePointer()) { + return (messenger->authSession() != nullptr); + } + return false; } AuthSession &AuthSession::Current() { diff --git a/Telegram/SourceFiles/intro/introwidget.cpp b/Telegram/SourceFiles/intro/introwidget.cpp index a094a3ee97..59b046d518 100644 --- a/Telegram/SourceFiles/intro/introwidget.cpp +++ b/Telegram/SourceFiles/intro/introwidget.cpp @@ -153,20 +153,12 @@ void Widget::historyMove(Direction direction) { if (direction == Direction::Back || direction == Direction::Replace) { delete base::take(wasStep); } - if (getStep()->hasBack()) { - _back->showAnimated(); - } else { - _back->hideAnimated(); - } - if (getStep()->hasCover()) { - _settings->hideAnimated(); - if (_update) _update->hideAnimated(); - if (_changeLanguage) _changeLanguage->showAnimated(); - } else { - _settings->showAnimated(); - if (_update) _update->showAnimated(); - if (_changeLanguage) _changeLanguage->hideAnimated(); - } + _back->toggleAnimated(getStep()->hasBack()); + + auto stepHasCover = getStep()->hasCover(); + _settings->toggleAnimated(!stepHasCover); + if (_update) _update->toggleAnimated(!stepHasCover); + if (_changeLanguage) _changeLanguage->toggleAnimated(stepHasCover); _next->setText(getStep()->nextButtonText()); if (_resetAccount) _resetAccount->hideAnimated(); getStep()->showAnimated(direction);