From 5fe1175602d43a96147d25a7f5d30da16234d1e3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 30 Jun 2017 13:46:41 +0300 Subject: [PATCH] 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. --- Telegram/SourceFiles/history/history_widget.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 2e359c89e4..ecdb729626 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -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); - updateForwardingItemRemovedSubscription(); - updateForwardingTexts(); + for (auto i = _toForward.begin(); i != _toForward.end(); ++i) { + if (i->get() == item) { + i = _toForward.erase(i); + updateForwardingItemRemovedSubscription(); + updateForwardingTexts(); + break; + } } }); }