From a51db55ef278b949e184a241bed03b04b0acba77 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 7 Apr 2021 15:42:12 +0400 Subject: [PATCH] Allow changing GenericBox later. --- ui/layers/generic_box.cpp | 4 ++-- ui/layers/generic_box.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ui/layers/generic_box.cpp b/ui/layers/generic_box.cpp index 94888e8..447bf8c 100644 --- a/ui/layers/generic_box.cpp +++ b/ui/layers/generic_box.cpp @@ -16,7 +16,7 @@ namespace Ui { void GenericBox::prepare() { _init(this); - auto wrap = object_ptr(this, std::move(_content)); + auto wrap = object_ptr(this, std::move(_owned)); setDimensionsToContent(_width ? _width : st::boxWidth, wrap.data()); setInnerWidget(std::move(wrap)); } @@ -26,7 +26,7 @@ void GenericBox::addSkip(int height) { } not_null GenericBox::verticalLayout() { - return _content.data(); + return _content; } } // namespace Ui diff --git a/ui/layers/generic_box.h b/ui/layers/generic_box.h index e0bceca..b6832f8 100644 --- a/ui/layers/generic_box.h +++ b/ui/layers/generic_box.h @@ -120,7 +120,8 @@ private: FnMut)> _init; Fn _focus; Fn _showFinished; - object_ptr _content; + object_ptr _owned; + not_null _content; int _width = 0; }; @@ -166,7 +167,8 @@ inline GenericBox::GenericBox( MakeIniter( std::forward(init), std::forward(args)...)) -, _content(this) { +, _owned(this) +, _content(_owned.data()) { } } // namespace Ui