From a9422111a28c6d18b8f0f95ce205a682ef4926a1 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 12 Apr 2021 17:46:46 +0400 Subject: [PATCH] Fix crash in leaving Recent Actions with GIFs. --- .../history/admin_log/history_admin_log_inner.cpp | 3 +++ .../history/admin_log/history_admin_log_item.cpp | 6 +++++- .../SourceFiles/history/admin_log/history_admin_log_item.h | 7 ++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index e9ee9b9eb..bbf58c9d7 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -632,6 +632,9 @@ void InnerWidget::saveState(not_null memento) { memento->setAdminsCanEdit(std::move(_adminsCanEdit)); memento->setSearchQuery(std::move(_searchQuery)); if (!_filterChanged) { + for (auto &item : _items) { + item.clearView(); + } memento->setItems( base::take(_items), base::take(_eventIds), diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp index 3f6234d64..b0b878b4b 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -480,7 +480,7 @@ OwnedItem &OwnedItem::operator=(OwnedItem &&other) { } OwnedItem::~OwnedItem() { - _view = nullptr; + clearView(); if (_data) { _data->destroy(); } @@ -491,6 +491,10 @@ void OwnedItem::refreshView( _view = _data->createView(delegate); } +void OwnedItem::clearView() { + _view = nullptr; +} + void GenerateItems( not_null delegate, not_null history, diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.h b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.h index ceaa50bc3..c7a74b8fa 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.h +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.h @@ -37,17 +37,18 @@ public: OwnedItem &operator=(OwnedItem &&other); ~OwnedItem(); - HistoryView::Element *get() const { + [[nodiscard]] HistoryView::Element *get() const { return _view.get(); } - HistoryView::Element *operator->() const { + [[nodiscard]] HistoryView::Element *operator->() const { return get(); } - operator HistoryView::Element*() const { + [[nodiscard]] operator HistoryView::Element*() const { return get(); } void refreshView(not_null delegate); + void clearView(); private: HistoryItem *_data = nullptr;