From b12f98db98dc0b28113bee42cda8b615fcbfd1f7 Mon Sep 17 00:00:00 2001 From: uramer Date: Tue, 12 Mar 2024 17:46:38 +0100 Subject: [PATCH] Don't destroy root widget for new elements --- components/lua_ui/element.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/components/lua_ui/element.cpp b/components/lua_ui/element.cpp index b491acb7b3..9d45f6ed7f 100644 --- a/components/lua_ui/element.cpp +++ b/components/lua_ui/element.cpp @@ -313,11 +313,14 @@ namespace LuaUi { if (mState != Destroyed) { - destroyRoot(mRoot); - mRoot = nullptr; if (mState != New) - mLayout = sol::make_object(mLayout.lua_state(), sol::nil); - mState = Destroyed; + { + assert(mRoot); + destroyRoot(mRoot); + mRoot = nullptr; + } + mLayout = sol::make_object(mLayout.lua_state(), sol::nil); } + mState = Destroyed; } }