mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix possible crash in nested section show.
This commit is contained in:
parent
454c8db00d
commit
dffe79fea8
1 changed files with 10 additions and 8 deletions
|
@ -759,9 +759,9 @@ bool WrapWidget::returnToFirstStackFrame(
|
||||||
void WrapWidget::showNewContent(
|
void WrapWidget::showNewContent(
|
||||||
not_null<ContentMemento*> memento,
|
not_null<ContentMemento*> memento,
|
||||||
const Window::SectionShow ¶ms) {
|
const Window::SectionShow ¶ms) {
|
||||||
auto saveToStack = (_content != nullptr)
|
const auto saveToStack = (_content != nullptr)
|
||||||
&& (params.way == Window::SectionShow::Way::Forward);
|
&& (params.way == Window::SectionShow::Way::Forward);
|
||||||
auto needAnimation = (_content != nullptr)
|
const auto needAnimation = (_content != nullptr)
|
||||||
&& (params.animated != anim::type::instant);
|
&& (params.animated != anim::type::instant);
|
||||||
auto animationParams = SectionSlideParams();
|
auto animationParams = SectionSlideParams();
|
||||||
auto newController = createController(
|
auto newController = createController(
|
||||||
|
@ -771,8 +771,12 @@ void WrapWidget::showNewContent(
|
||||||
newController->takeStepData(_controller.get());
|
newController->takeStepData(_controller.get());
|
||||||
}
|
}
|
||||||
auto newContent = object_ptr<ContentWidget>(nullptr);
|
auto newContent = object_ptr<ContentWidget>(nullptr);
|
||||||
if (needAnimation) {
|
const auto enableBackButton = hasBackButton();
|
||||||
|
const auto createInAdvance = needAnimation || enableBackButton;
|
||||||
|
if (createInAdvance) {
|
||||||
newContent = createContent(memento, newController.get());
|
newContent = createContent(memento, newController.get());
|
||||||
|
}
|
||||||
|
if (needAnimation) {
|
||||||
animationParams.withTopBarShadow = hasTopBarShadow()
|
animationParams.withTopBarShadow = hasTopBarShadow()
|
||||||
&& newContent->hasTopBarShadow();
|
&& newContent->hasTopBarShadow();
|
||||||
animationParams.oldContentCache = grabForShowAnimation(
|
animationParams.oldContentCache = grabForShowAnimation(
|
||||||
|
@ -783,7 +787,6 @@ void WrapWidget::showNewContent(
|
||||||
|
|
||||||
if (HasCustomTopBar(_controller.get())
|
if (HasCustomTopBar(_controller.get())
|
||||||
|| HasCustomTopBar(newController.get())) {
|
|| HasCustomTopBar(newController.get())) {
|
||||||
|
|
||||||
const auto s = QSize(
|
const auto s = QSize(
|
||||||
newContent->width(),
|
newContent->width(),
|
||||||
animationParams.topSkip);
|
animationParams.topSkip);
|
||||||
|
@ -803,11 +806,10 @@ void WrapWidget::showNewContent(
|
||||||
_historyStack.clear();
|
_historyStack.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if (enableBackButton) {
|
||||||
if (hasBackButton()) {
|
newContent->enableBackButton();
|
||||||
newContent->enableBackButton();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Let old controller outlive old content widget.
|
// Let old controller outlive old content widget.
|
||||||
const auto oldController = std::exchange(
|
const auto oldController = std::exchange(
|
||||||
|
|
Loading…
Add table
Reference in a new issue