mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-30 04:11:34 +00:00
Set Element layout to nil on destroy (!2770 for 0.48)
This commit is contained in:
parent
95219e6fa2
commit
ed5e0ff4f3
2 changed files with 16 additions and 13 deletions
|
@ -190,8 +190,8 @@ namespace LuaUi
|
|||
assert(!mRoot);
|
||||
if (!mRoot)
|
||||
{
|
||||
mRoot = createWidget(mLayout, 0);
|
||||
mLayer = setLayer(mRoot, mLayout);
|
||||
mRoot = createWidget(layout(), 0);
|
||||
mLayer = setLayer(mRoot, layout());
|
||||
updateAttachment();
|
||||
}
|
||||
}
|
||||
|
@ -200,16 +200,16 @@ namespace LuaUi
|
|||
{
|
||||
if (mRoot && mUpdate)
|
||||
{
|
||||
if (mRoot->widget()->getTypeName() != widgetType(mLayout))
|
||||
if (mRoot->widget()->getTypeName() != widgetType(layout()))
|
||||
{
|
||||
destroyWidget(mRoot);
|
||||
mRoot = createWidget(mLayout, 0);
|
||||
mRoot = createWidget(layout(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateWidget(mRoot, mLayout, 0);
|
||||
updateWidget(mRoot, layout(), 0);
|
||||
}
|
||||
mLayer = setLayer(mRoot, mLayout);
|
||||
mLayer = setLayer(mRoot, layout());
|
||||
updateAttachment();
|
||||
}
|
||||
mUpdate = false;
|
||||
|
@ -217,9 +217,11 @@ namespace LuaUi
|
|||
|
||||
void Element::destroy()
|
||||
{
|
||||
if (mRoot)
|
||||
destroyWidget(mRoot);
|
||||
if (!mRoot)
|
||||
return;
|
||||
destroyWidget(mRoot);
|
||||
mRoot = nullptr;
|
||||
mLayout = sol::make_object(mLayout.lua_state(), sol::nil);
|
||||
sAllElements.erase(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace LuaUi
|
|||
|
||||
WidgetExtension* mRoot;
|
||||
WidgetExtension* mAttachedTo;
|
||||
sol::table mLayout;
|
||||
sol::object mLayout;
|
||||
std::string mLayer;
|
||||
bool mUpdate;
|
||||
bool mDestroy;
|
||||
|
@ -34,10 +34,11 @@ namespace LuaUi
|
|||
void attachToWidget(WidgetExtension* w);
|
||||
void detachFromWidget();
|
||||
|
||||
private:
|
||||
Element(sol::table layout);
|
||||
static std::map<Element*, std::shared_ptr<Element>> sAllElements;
|
||||
void updateAttachment();
|
||||
private:
|
||||
Element(sol::table layout);
|
||||
sol::table layout() { return mLayout.as<sol::table>(); }
|
||||
static std::map<Element*, std::shared_ptr<Element>> sAllElements;
|
||||
void updateAttachment();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue