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:
parent
bf57a1506f
commit
5fe1175602
|
@ -6414,14 +6414,13 @@ void HistoryWidget::updateForwardingItemRemovedSubscription() {
|
||||||
_forwardingItemRemovedSubscription = 0;
|
_forwardingItemRemovedSubscription = 0;
|
||||||
} else if (!_forwardingItemRemovedSubscription) {
|
} else if (!_forwardingItemRemovedSubscription) {
|
||||||
_forwardingItemRemovedSubscription = subscribe(Global::RefItemRemoved(), [this](HistoryItem *item) {
|
_forwardingItemRemovedSubscription = subscribe(Global::RefItemRemoved(), [this](HistoryItem *item) {
|
||||||
auto i = _toForward.find(item->id);
|
for (auto i = _toForward.begin(); i != _toForward.end(); ++i) {
|
||||||
if (i == _toForward.cend() || i.value() != item) {
|
if (i->get() == item) {
|
||||||
i = _toForward.find(item->id - ServerMaxMsgId);
|
i = _toForward.erase(i);
|
||||||
}
|
|
||||||
if (i != _toForward.cend() && i.value() == item) {
|
|
||||||
_toForward.erase(i);
|
|
||||||
updateForwardingItemRemovedSubscription();
|
updateForwardingItemRemovedSubscription();
|
||||||
updateForwardingTexts();
|
updateForwardingTexts();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue