From bb35d71fdc919e9835dad2474c308812bff7d013 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 10 Mar 2018 15:47:19 +0300 Subject: [PATCH] Attempt to fix access to a deleted item view. --- Telegram/SourceFiles/history/history_item.cpp | 1 - Telegram/SourceFiles/history/history_item.h | 2 +- Telegram/SourceFiles/history/view/history_view_element.cpp | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 39f6d5da7..71014e4e6 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -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(); } } diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 62000e511..39f0fc1e9 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -100,7 +100,7 @@ public: HistoryView::Element *mainView() const { return _mainView; } - void setMainView(HistoryView::Element *view) { + void setMainView(not_null view) { _mainView = view; } void refreshMainView(); diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index 11a0a77e2..c5603d76c 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -629,6 +629,9 @@ Element::~Element() { if (_data->mainView() == this) { _data->clearMainView(); } + if (_context == Context::History) { + Auth().data().notifyViewRemoved(this); + } Auth().data().unregisterItemView(this); }