From 13ad39dfc231c7710c2c8029396bdd78c6ebc1ea Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 29 Dec 2022 10:48:33 +0400 Subject: [PATCH] Fix possible crash in logout. --- Telegram/SourceFiles/window/window_main_menu.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 979a586aec..33a4575da5 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -956,8 +956,12 @@ OthersUnreadState OtherAccountsUnreadStateCurrent() { } } } + // In case we are logging out in the last paint for the slide animation + // the account doesn't have the session here already. + const auto current = active->maybeSession(); return { - .count = (app.unreadBadge() - active->session().data().unreadBadge()), + .count = (app.unreadBadge() + - (current ? current->data().unreadBadge() : 0)), .allMuted = allMuted, }; }