From b32b98d9f587a8b7d72c7d4c1a08dc74dc655696 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Tue, 9 Dec 2025 15:41:02 +0100 Subject: [PATCH] Detach elements from child before destroying it --- components/lua_ui/element.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/components/lua_ui/element.cpp b/components/lua_ui/element.cpp index e54993cfc7..d3bdfc4114 100644 --- a/components/lua_ui/element.cpp +++ b/components/lua_ui/element.cpp @@ -49,14 +49,6 @@ namespace LuaUi MyGUI::Gui::getInstancePtr()->destroyWidget(ext->widget()); } - void destroyChild(WidgetExtension* ext) - { - if (!ext->isRoot()) - destroyWidget(ext); - else - ext->detachFromParent(); - } - void detachElements(WidgetExtension* ext) { auto predicate = [](WidgetExtension* child) { @@ -69,6 +61,17 @@ namespace LuaUi ext->detachTemplateChildrenIf(predicate); } + void destroyChild(WidgetExtension* ext) + { + if (!ext->isRoot()) + { + detachElements(ext); + destroyWidget(ext); + } + else + ext->detachFromParent(); + } + void destroyRoot(WidgetExtension* ext) { detachElements(ext);