Fix possible crash in dialogs saved peers.

This commit is contained in:
John Preston 2018-12-05 11:10:50 +04:00
parent 0e38671224
commit edadc51e05

View File

@ -1842,10 +1842,13 @@ void DialogsInner::applyDialog(const MTPDdialog &dialog) {
void DialogsInner::addSavedPeersAfter(const QDateTime &date) {
auto &saved = cRefSavedPeersByTime();
while (!saved.isEmpty() && (date.isNull() || date < saved.lastKey())) {
const auto history = App::history(saved.last()->id);
history->setChatsListTimeId(ServerTimeFromParsed(saved.lastKey()));
const auto lastDate = saved.lastKey();
const auto lastPeer = saved.last();
saved.remove(lastDate, lastPeer);
const auto history = App::history(lastPeer);
history->setChatsListTimeId(ServerTimeFromParsed(lastDate));
_contactsNoDialogs->del(history);
saved.remove(saved.lastKey(), saved.last());
}
}