mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-11 13:04:30 +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);
|
assert(!mRoot);
|
||||||
if (!mRoot)
|
if (!mRoot)
|
||||||
{
|
{
|
||||||
mRoot = createWidget(mLayout, 0);
|
mRoot = createWidget(layout(), 0);
|
||||||
mLayer = setLayer(mRoot, mLayout);
|
mLayer = setLayer(mRoot, layout());
|
||||||
updateAttachment();
|
updateAttachment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -200,16 +200,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;
|
||||||
|
|
@ -217,9 +217,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;
|
||||||
|
|
@ -34,10 +34,11 @@ namespace LuaUi
|
||||||
void attachToWidget(WidgetExtension* w);
|
void attachToWidget(WidgetExtension* w);
|
||||||
void detachFromWidget();
|
void detachFromWidget();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Element(sol::table layout);
|
Element(sol::table layout);
|
||||||
static std::map<Element*, std::shared_ptr<Element>> sAllElements;
|
sol::table layout() { return mLayout.as<sol::table>(); }
|
||||||
void updateAttachment();
|
static std::map<Element*, std::shared_ptr<Element>> sAllElements;
|
||||||
|
void updateAttachment();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue