1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-19 02:11:33 +00:00

Extend lifetime of strings placed on the action queue

This commit is contained in:
Evil Eye 2025-03-03 19:36:54 +01:00
parent 62d1cdcdac
commit f0cee09b7c

View file

@ -168,7 +168,8 @@ namespace MWLua
if (index == LuaUi::Layer::count()) if (index == LuaUi::Layer::count())
throw std::logic_error(std::string("Layer not found")); throw std::logic_error(std::string("Layer not found"));
index++; index++;
context.mLuaManager->addAction([=]() { LuaUi::Layer::insert(index, name, options); }, "Insert UI layer"); context.mLuaManager->addAction(
[=, name = std::string(name)]() { LuaUi::Layer::insert(index, name, options); }, "Insert UI layer");
}; };
layersTable["insertBefore"] = [context]( layersTable["insertBefore"] = [context](
std::string_view beforename, std::string_view name, const sol::object& opt) { std::string_view beforename, std::string_view name, const sol::object& opt) {
@ -177,7 +178,8 @@ namespace MWLua
size_t index = LuaUi::Layer::indexOf(beforename); size_t index = LuaUi::Layer::indexOf(beforename);
if (index == LuaUi::Layer::count()) if (index == LuaUi::Layer::count())
throw std::logic_error(std::string("Layer not found")); throw std::logic_error(std::string("Layer not found"));
context.mLuaManager->addAction([=]() { LuaUi::Layer::insert(index, name, options); }, "Insert UI layer"); context.mLuaManager->addAction(
[=, name = std::string(name)]() { LuaUi::Layer::insert(index, name, options); }, "Insert UI layer");
}; };
sol::table layers = LuaUtil::makeReadOnly(layersTable); sol::table layers = LuaUtil::makeReadOnly(layersTable);
sol::table layersMeta = layers[sol::metatable_key]; sol::table layersMeta = layers[sol::metatable_key];
@ -285,7 +287,7 @@ namespace MWLua
return res; return res;
}; };
api["_setWindowDisabled"] api["_setWindowDisabled"]
= [windowManager, luaManager = context.mLuaManager](std::string_view window, bool disabled) { = [windowManager, luaManager = context.mLuaManager](std::string window, bool disabled) {
luaManager->addAction([=]() { windowManager->setDisabledByLua(window, disabled); }); luaManager->addAction([=]() { windowManager->setDisabledByLua(window, disabled); });
}; };