From c2c058517ce985228eb1986cb0c2e07d526aa16d Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 21 Aug 2026 12:31:27 +0400 Subject: [PATCH] Rebind Info wrap teardown when a sublist is replaced Task: 2026/08/21/resubscribe-info-wrap-teardown-on-replaced-sublist --- Telegram/SourceFiles/info/info_wrap_widget.cpp | 12 ++++++++---- Telegram/SourceFiles/info/info_wrap_widget.h | 2 ++ ...bscribe-info-wrap-teardown-on-replaced-sublist.md | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 tasks/2026/08/21/resubscribe-info-wrap-teardown-on-replaced-sublist.md diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index baec1fe85a..2d9a9b580e 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -146,7 +146,11 @@ WrapWidget::WrapWidget( }); }, lifetime()); restoreHistoryStack(memento->takeStack()); + subscribeToThreadDestroyed(); +} +void WrapWidget::subscribeToThreadDestroyed() { + _threadDestroyedLifetime.destroy(); if (const auto topic = _controller->topic()) { topic->destroyed( ) | rpl::on_next([=] { @@ -160,9 +164,8 @@ WrapWidget::WrapWidget( } else { _removeRequests.fire({}); } - }, lifetime()); - } - if (const auto sublist = _controller->sublist()) { + }, _threadDestroyedLifetime); + } else if (const auto sublist = _controller->sublist()) { sublist->destroyed( ) | rpl::on_next([=] { const auto parent = _controller->parentController(); @@ -175,7 +178,7 @@ WrapWidget::WrapWidget( Window::SectionShow::Way::ClearStack, anim::type::instant)); _removeRequests.fire({}); - }, lifetime()); + }, _threadDestroyedLifetime); } } @@ -1040,6 +1043,7 @@ void WrapWidget::showNewContent( showNewContent(memento); } } + subscribeToThreadDestroyed(); if (animationParams) { if (Ui::InFocusChain(this)) { diff --git a/Telegram/SourceFiles/info/info_wrap_widget.h b/Telegram/SourceFiles/info/info_wrap_widget.h index 25c0510c38..29052b4390 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.h +++ b/Telegram/SourceFiles/info/info_wrap_widget.h @@ -188,6 +188,7 @@ private: void showNewContent( not_null memento, const Window::SectionShow ¶ms); + void subscribeToThreadDestroyed(); bool returnToFirstStackFrame( not_null memento, const Window::SectionShow ¶ms); @@ -246,6 +247,7 @@ private: std::vector _historyStack; rpl::event_stream<> _removeRequests; + rpl::lifetime _threadDestroyedLifetime; bool _shortcutsSetup = false; rpl::event_stream> _desiredHeights; diff --git a/tasks/2026/08/21/resubscribe-info-wrap-teardown-on-replaced-sublist.md b/tasks/2026/08/21/resubscribe-info-wrap-teardown-on-replaced-sublist.md new file mode 100644 index 0000000000..19938199e8 --- /dev/null +++ b/tasks/2026/08/21/resubscribe-info-wrap-teardown-on-replaced-sublist.md @@ -0,0 +1 @@ +Info wrap `destroyed()` teardown now rebinds when `showNewContent` replaces the controller, using a wrap-owned lifetime so an old sublist cannot tear down a wrap that no longer shows it. The constructor path still subscribes.