diff options
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 |