diff --git a/Telegram/SourceFiles/history/view/history_view_chat_section.cpp b/Telegram/SourceFiles/history/view/history_view_chat_section.cpp index fc4cf0fc3c..7d96d7e0f9 100644 --- a/Telegram/SourceFiles/history/view/history_view_chat_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_chat_section.cpp @@ -456,7 +456,7 @@ ChatWidget::~ChatWidget() { if (_repliesRootId) { controller()->sendingAnimation().clear(); } - if (_subsectionTabs) { + if (_subsectionTabs && !_subsectionTabs->dying()) { _subsectionTabsLifetime.destroy(); controller()->saveSubsectionTabs(base::take(_subsectionTabs)); } diff --git a/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp b/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp index f1bb1f33c2..9d61f1c85e 100644 --- a/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp +++ b/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp @@ -510,6 +510,10 @@ void SubsectionTabs::toggleModes() { _layoutRequests.fire({}); } +bool SubsectionTabs::dying() const { + return !UsedFor(_history); +} + rpl::producer<> SubsectionTabs::removeRequests() const { if (const auto forum = _history->peer->forum()) { return forum->destroyed(); diff --git a/Telegram/SourceFiles/history/view/history_view_subsection_tabs.h b/Telegram/SourceFiles/history/view/history_view_subsection_tabs.h index 75a37104ea..d0d78f140c 100644 --- a/Telegram/SourceFiles/history/view/history_view_subsection_tabs.h +++ b/Telegram/SourceFiles/history/view/history_view_subsection_tabs.h @@ -49,6 +49,7 @@ public: [[nodiscard]] static bool UsedFor(not_null thread); + [[nodiscard]] bool dying() const; [[nodiscard]] rpl::producer<> removeRequests() const; void extractToParent(not_null parent);