From b3f5973329748c75a92b358a72c58c278cbcefb4 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 28 May 2019 14:33:42 +0200 Subject: [PATCH] Fix possible crash in calendar box. --- Telegram/SourceFiles/window/window_controller.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index c84110d698..d398fdf31d 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -500,8 +500,8 @@ void Controller::showJumpToDate(Dialogs::Key chat, QDate requestedDate) { // return ParseDateTime(feed->chatListTimeId()).date(); // } } - return QDate::currentDate(); - }; + return QDate(); + }(); const auto maxPeerDate = [](Dialogs::Key chat) { if (auto history = chat.history()) { if (const auto channel = history->peer->migrateTo()) { @@ -545,9 +545,11 @@ void Controller::showJumpToDate(Dialogs::Key chat, QDate requestedDate) { } return startDate(); }; - const auto highlighted = requestedDate.isNull() - ? currentPeerDate() - : requestedDate; + const auto highlighted = !requestedDate.isNull() + ? requestedDate + : !currentPeerDate.isNull() + ? currentPeerDate + : QDate::currentDate(); const auto month = highlighted; auto callback = [=](const QDate &date) { session().api().jumpToDate(chat, date);