mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 21:36:42 +00:00
Set Element layout to nil on destroy
This commit is contained in:
parent
9e468e7b73
commit
38bceb653d
2 changed files with 12 additions and 9 deletions
|
@ -189,8 +189,8 @@ namespace LuaUi
|
||||||
assert(!mRoot);
|
assert(!mRoot);
|
||||||
if (!mRoot)
|
if (!mRoot)
|
||||||
{
|
{
|
||||||
mRoot = createWidget(mLayout, 0);
|
mRoot = createWidget(layout(), 0);
|
||||||
mLayer = setLayer(mRoot, mLayout);
|
mLayer = setLayer(mRoot, layout());
|
||||||
updateAttachment();
|
updateAttachment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,16 +199,16 @@ namespace LuaUi
|
||||||
{
|
{
|
||||||
if (mRoot && mUpdate)
|
if (mRoot && mUpdate)
|
||||||
{
|
{
|
||||||
if (mRoot->widget()->getTypeName() != widgetType(mLayout))
|
if (mRoot->widget()->getTypeName() != widgetType(layout()))
|
||||||
{
|
{
|
||||||
destroyWidget(mRoot);
|
destroyWidget(mRoot);
|
||||||
mRoot = createWidget(mLayout, 0);
|
mRoot = createWidget(layout(), 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
updateWidget(mRoot, mLayout, 0);
|
updateWidget(mRoot, layout(), 0);
|
||||||
}
|
}
|
||||||
mLayer = setLayer(mRoot, mLayout);
|
mLayer = setLayer(mRoot, layout());
|
||||||
updateAttachment();
|
updateAttachment();
|
||||||
}
|
}
|
||||||
mUpdate = false;
|
mUpdate = false;
|
||||||
|
@ -216,9 +216,11 @@ namespace LuaUi
|
||||||
|
|
||||||
void Element::destroy()
|
void Element::destroy()
|
||||||
{
|
{
|
||||||
if (mRoot)
|
if (!mRoot)
|
||||||
destroyWidget(mRoot);
|
return;
|
||||||
|
destroyWidget(mRoot);
|
||||||
mRoot = nullptr;
|
mRoot = nullptr;
|
||||||
|
mLayout = sol::make_object(mLayout.lua_state(), sol::nil);
|
||||||
sAllElements.erase(this);
|
sAllElements.erase(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace LuaUi
|
||||||
|
|
||||||
WidgetExtension* mRoot;
|
WidgetExtension* mRoot;
|
||||||
WidgetExtension* mAttachedTo;
|
WidgetExtension* mAttachedTo;
|
||||||
sol::table mLayout;
|
sol::object mLayout;
|
||||||
std::string mLayer;
|
std::string mLayer;
|
||||||
bool mUpdate;
|
bool mUpdate;
|
||||||
bool mDestroy;
|
bool mDestroy;
|
||||||
|
@ -36,6 +36,7 @@ namespace LuaUi
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Element(sol::table layout);
|
Element(sol::table layout);
|
||||||
|
sol::table layout() { return mLayout.as<sol::table>(); }
|
||||||
static std::map<Element*, std::shared_ptr<Element>> sAllElements;
|
static std::map<Element*, std::shared_ptr<Element>> sAllElements;
|
||||||
void updateAttachment();
|
void updateAttachment();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue