diff options
author | crupest <crupest@outlook.com> | 2022-02-16 23:41:28 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-16 23:41:28 +0800 |
commit | 77e0fd5cf7dd35324a7c3a43f2004fb923c6254c (patch) | |
tree | 0d66fd74fa61bb680ac0ae35c9faa4e5d853f295 /src/ui/controls | |
parent | 9307bd1af7c52aaf9c6d25b598bf3069a63c32a1 (diff) | |
download | cru-77e0fd5cf7dd35324a7c3a43f2004fb923c6254c.tar.gz cru-77e0fd5cf7dd35324a7c3a43f2004fb923c6254c.tar.bz2 cru-77e0fd5cf7dd35324a7c3a43f2004fb923c6254c.zip |
...
Diffstat (limited to 'src/ui/controls')
-rw-r--r-- | src/ui/controls/Control.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/ui/controls/Control.cpp b/src/ui/controls/Control.cpp index 43faba69..f2d4760e 100644 --- a/src/ui/controls/Control.cpp +++ b/src/ui/controls/Control.cpp @@ -27,7 +27,10 @@ Control::Control() { }); } -Control::~Control() { RemoveFromParent(); } +Control::~Control() { + in_destruction_ = true; + RemoveFromParent(); +} void Control::SetParent(Control* parent) { if (parent_ == parent) return; @@ -111,7 +114,7 @@ void Control::OnParentChangedCore(Control* old_parent, Control* new_parent) { OnWindowHostChangedCore(old_host, new_window_host); } - OnParentChanged(old_parent, new_parent); + if (!in_destruction_) OnParentChanged(old_parent, new_parent); } void Control::OnWindowHostChangedCore(host::WindowHost* old_host, @@ -125,10 +128,12 @@ void Control::OnWindowHostChangedCore(host::WindowHost* old_host, } } - ForEachChild([old_host, new_host](Control* child) { - child->window_host_ = new_host; - child->OnWindowHostChangedCore(old_host, new_host); - }); - OnWindowHostChanged(old_host, new_host); + if (!in_destruction_) { + ForEachChild([old_host, new_host](Control* child) { + child->window_host_ = new_host; + child->OnWindowHostChangedCore(old_host, new_host); + }); + OnWindowHostChanged(old_host, new_host); + } } } // namespace cru::ui::controls |