From ee0f66d7468de582fc85c464dbcb0b5c6ae1f25b Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 6 Sep 2019 10:33:05 +0300 Subject: [PATCH] Fix crash in history clear while sending messages. Don't remove messages that are currently being sent from locals. --- Telegram/SourceFiles/history/history.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 326338e348..0df87b3885 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -3060,8 +3060,16 @@ void History::clear(ClearType type) { lastKeyboardInited = false; _loadedAtTop = _loadedAtBottom = false; } else { + // Leave the 'sending' messages in local messages. + for (auto i = begin(_localMessages); i != end(_localMessages);) { + const auto item = *i; + if (!item->isSending()) { + i = _localMessages.erase(i); + } else { + ++i; + } + } _notifications.clear(); - _localMessages.clear(); owner().notifyHistoryCleared(this); if (unreadCountKnown()) { setUnreadCount(0);