Fix crash in forwarding messages.

HistoryHider holds pointers to items, so it should watch for
the history items being removed and remove the pointers.
This commit is contained in:
John Preston 2017-07-13 17:57:25 +03:00
parent e0c74c9546
commit a69304fd25
1 changed files with 13 additions and 0 deletions

View File

@ -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(); });