Attempt to fix access to a deleted item view.

This commit is contained in:
John Preston 2018-03-10 15:47:19 +03:00
parent 42a7e86e51
commit bb35d71fdc
3 changed files with 4 additions and 2 deletions

View file

@ -268,7 +268,6 @@ void HistoryItem::refreshMainView() {
void HistoryItem::removeMainView() {
if (const auto view = mainView()) {
Auth().data().notifyHistoryChangeDelayed(_history);
Auth().data().notifyViewRemoved(view);
view->removeFromBlock();
}
}

View file

@ -100,7 +100,7 @@ public:
HistoryView::Element *mainView() const {
return _mainView;
}
void setMainView(HistoryView::Element *view) {
void setMainView(not_null<HistoryView::Element*> view) {
_mainView = view;
}
void refreshMainView();

View file

@ -629,6 +629,9 @@ Element::~Element() {
if (_data->mainView() == this) {
_data->clearMainView();
}
if (_context == Context::History) {
Auth().data().notifyViewRemoved(this);
}
Auth().data().unregisterItemView(this);
}