Fix crash in history clear while sending messages.

Don't remove messages that are currently being sent from locals.
This commit is contained in:
John Preston 2019-09-06 10:33:05 +03:00
parent 7893ad0558
commit ee0f66d746

View File

@ -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);