Version 1.8.4: Fix crash in local messages.

This commit is contained in:
John Preston 2019-09-06 16:41:43 +03:00
parent 30f4d870c5
commit d7cb8b7065
1 changed files with 6 additions and 5 deletions

View File

@ -3060,14 +3060,15 @@ void History::clear(ClearType type) {
_loadedAtTop = _loadedAtBottom = false; _loadedAtTop = _loadedAtBottom = false;
} else { } else {
// Leave the 'sending' messages in local messages. // Leave the 'sending' messages in local messages.
for (auto i = begin(_localMessages); i != end(_localMessages);) { auto local = base::flat_set<not_null<HistoryItem*>>();
const auto item = *i; for (const auto item : _localMessages) {
if (!item->isSending()) { if (!item->isSending()) {
i = _localMessages.erase(i); local.emplace(item);
} else {
++i;
} }
} }
for (const auto item : local) {
item->destroy();
}
_notifications.clear(); _notifications.clear();
owner().notifyHistoryCleared(this); owner().notifyHistoryCleared(this);
if (unreadCountKnown()) { if (unreadCountKnown()) {