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() { void HistoryItem::removeMainView() {
if (const auto view = mainView()) { if (const auto view = mainView()) {
Auth().data().notifyHistoryChangeDelayed(_history); Auth().data().notifyHistoryChangeDelayed(_history);
Auth().data().notifyViewRemoved(view);
view->removeFromBlock(); view->removeFromBlock();
} }
} }

View file

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

View file

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