From d7cb8b706570e01e6cdea5ab49d4425c210f3408 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 6 Sep 2019 16:41:43 +0300 Subject: [PATCH] Version 1.8.4: Fix crash in local messages. --- Telegram/SourceFiles/history/history.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index b1dd74e540..957b71b215 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -3060,14 +3060,15 @@ void History::clear(ClearType type) { _loadedAtTop = _loadedAtBottom = false; } else { // Leave the 'sending' messages in local messages. - for (auto i = begin(_localMessages); i != end(_localMessages);) { - const auto item = *i; + auto local = base::flat_set>(); + for (const auto item : _localMessages) { if (!item->isSending()) { - i = _localMessages.erase(i); - } else { - ++i; + local.emplace(item); } } + for (const auto item : local) { + item->destroy(); + } _notifications.clear(); owner().notifyHistoryCleared(this); if (unreadCountKnown()) {