diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-11-19 02:59:30 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-11-19 02:59:30 +0800 |
| commit | 2eb34dfc3dd3ca718da6ebf049886b4ae140b332 (patch) | |
| tree | c43dbca6e6898fd474ca9b976b4bf21b3419e512 /src/ui/controls/Control.cpp | |
| parent | df2dadbd0f0ace6e02281c84218537ec2ce5c47f (diff) | |
| download | cru-2eb34dfc3dd3ca718da6ebf049886b4ae140b332.tar.gz cru-2eb34dfc3dd3ca718da6ebf049886b4ae140b332.tar.bz2 cru-2eb34dfc3dd3ca718da6ebf049886b4ae140b332.zip | |
Remove all children when control destroyed.
Diffstat (limited to 'src/ui/controls/Control.cpp')
| -rw-r--r-- | src/ui/controls/Control.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/ui/controls/Control.cpp b/src/ui/controls/Control.cpp index 02148b72..70a3b1f3 100644 --- a/src/ui/controls/Control.cpp +++ b/src/ui/controls/Control.cpp @@ -27,6 +27,7 @@ Control::~Control() { } RemoveFromParent(); + RemoveAllChild(); } std::string Control::GetDebugId() const { @@ -89,9 +90,8 @@ void Control::InsertChildAt(Control* control, Index index) { children_.insert(children_.cbegin() + index, control); control->parent_ = this; - - TraverseDescendents([this](Control* control) { control->host_ = host_; }, - false); + control->TraverseDescendents( + [this](Control* control) { control->host_ = host_; }, true); if (host_) { host_->NotifyControlParentChange(control, nullptr, this); } @@ -111,8 +111,8 @@ void Control::RemoveChildAt(Index index) { auto control = children_[index]; children_.erase(children_.cbegin() + index); control->parent_ = nullptr; - TraverseDescendents([this](Control* control) { control->host_ = nullptr; }, - false); + control->TraverseDescendents( + [this](Control* control) { control->host_ = nullptr; }, true); if (host_) { host_->NotifyControlParentChange(control, this, nullptr); } |
