From a69304fd2547961f684f249a7ea590bbf604f736 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 13 Jul 2017 17:57:25 +0300 Subject: [PATCH] Fix crash in forwarding messages. HistoryHider holds pointers to items, so it should watch for the history items being removed and remove the pointers. --- Telegram/SourceFiles/history/history_widget.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 0775c4a715..949781dda6 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -208,6 +208,19 @@ HistoryHider::HistoryHider(MainWidget *parent, const QString &url, const QString void HistoryHider::init() { subscribe(Lang::Current().updated(), [this] { refreshLang(); }); + if (!_forwardItems.empty()) { + subscribe(Global::RefItemRemoved(), [this](HistoryItem *item) { + for (auto i = _forwardItems.begin(); i != _forwardItems.end(); ++i) { + if (i->get() == item) { + i = _forwardItems.erase(i); + break; + } + } + if (_forwardItems.empty()) { + startHide(); + } + }); + } connect(_send, SIGNAL(clicked()), this, SLOT(forward())); connect(_cancel, SIGNAL(clicked()), this, SLOT(startHide())); subscribe(Global::RefPeerChooseCancel(), [this] { startHide(); });