Rebind Info wrap teardown when a sublist is replaced

Task: 2026/08/21/resubscribe-info-wrap-teardown-on-replaced-sublist
This commit is contained in:
John Preston
2026-08-21 12:31:27 +04:00
committed by 23rd
parent ddbc3cef68
commit c2c058517c
3 changed files with 11 additions and 4 deletions

View File

@@ -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)) {

View File

@@ -188,6 +188,7 @@ private:
void showNewContent(
not_null<ContentMemento*> memento,
const Window::SectionShow &params);
void subscribeToThreadDestroyed();
bool returnToFirstStackFrame(
not_null<ContentMemento*> memento,
const Window::SectionShow &params);
@@ -246,6 +247,7 @@ private:
std::vector<StackItem> _historyStack;
rpl::event_stream<> _removeRequests;
rpl::lifetime _threadDestroyedLifetime;
bool _shortcutsSetup = false;
rpl::event_stream<rpl::producer<int>> _desiredHeights;

View File

@@ -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.