Fix crash on launch with passcode.

This commit is contained in:
John Preston 2022-06-15 14:49:06 +04:00
parent 014cd19e93
commit aa484ac015
3 changed files with 16 additions and 9 deletions

View file

@ -797,13 +797,11 @@ void Application::handleAppDeactivated() {
if (_primaryWindow) { if (_primaryWindow) {
_primaryWindow->updateIsActiveBlur(); _primaryWindow->updateIsActiveBlur();
} }
if (_domain->started()) { const auto session = _lastActiveWindow
const auto session = _lastActiveWindow ? _lastActiveWindow->maybeSession()
? _lastActiveWindow->account().maybeSession() : nullptr;
: nullptr; if (session) {
if (session) { session->updates().updateOnline();
session->updates().updateOnline();
}
} }
Ui::Tooltip::Hide(); Ui::Tooltip::Hide();
} }
@ -1235,8 +1233,8 @@ void Application::windowActivated(not_null<Window::Controller*> window) {
const auto now = window; const auto now = window;
_lastActiveWindow = window; _lastActiveWindow = window;
const auto wasSession = was ? was->account().maybeSession() : nullptr; const auto wasSession = was ? was->maybeSession() : nullptr;
const auto nowSession = now->account().maybeSession(); const auto nowSession = now->maybeSession();
if (wasSession != nowSession) { if (wasSession != nowSession) {
if (wasSession) { if (wasSession) {
wasSession->updates().updateOnline(); wasSession->updates().updateOnline();

View file

@ -251,6 +251,10 @@ void Controller::finishFirstShow() {
checkThemeEditor(); checkThemeEditor();
} }
Main::Session *Controller::maybeSession() const {
return _account ? _account->maybeSession() : nullptr;
}
bool Controller::locked() const { bool Controller::locked() const {
if (Core::App().passcodeLocked()) { if (Core::App().passcodeLocked()) {
return true; return true;

View file

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Main { namespace Main {
class Account; class Account;
class Session;
} // namespace Main } // namespace Main
namespace Media::View { namespace Media::View {
@ -46,6 +47,10 @@ public:
return *_account; return *_account;
} }
[[nodiscard]] Main::Account *maybeAccount() const {
return _account;
}
[[nodiscard]] Main::Session *maybeSession() const;
[[nodiscard]] SessionController *sessionController() const { [[nodiscard]] SessionController *sessionController() const {
return _sessionController.get(); return _sessionController.get();
} }