Fix crash when message for forward is deleted.

The messages prepared for forwarding are not a map (MsgId -> item),
but just a map (random int -> item), so we need to loop over them.
This commit is contained in:
John Preston 2017-06-30 13:46:41 +03:00
parent bf57a1506f
commit 5fe1175602
1 changed files with 7 additions and 8 deletions

View File

@ -6414,14 +6414,13 @@ void HistoryWidget::updateForwardingItemRemovedSubscription() {
_forwardingItemRemovedSubscription = 0;
} else if (!_forwardingItemRemovedSubscription) {
_forwardingItemRemovedSubscription = subscribe(Global::RefItemRemoved(), [this](HistoryItem *item) {
auto i = _toForward.find(item->id);
if (i == _toForward.cend() || i.value() != item) {
i = _toForward.find(item->id - ServerMaxMsgId);
}
if (i != _toForward.cend() && i.value() == item) {
_toForward.erase(i);
for (auto i = _toForward.begin(); i != _toForward.end(); ++i) {
if (i->get() == item) {
i = _toForward.erase(i);
updateForwardingItemRemovedSubscription();
updateForwardingTexts();
break;
}
}
});
}