diff --git a/apps/openmw/mwlua/uibindings.cpp b/apps/openmw/mwlua/uibindings.cpp index 9652df1238..069258fd8e 100644 --- a/apps/openmw/mwlua/uibindings.cpp +++ b/apps/openmw/mwlua/uibindings.cpp @@ -168,7 +168,8 @@ namespace MWLua if (index == LuaUi::Layer::count()) throw std::logic_error(std::string("Layer not found")); 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]( 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); if (index == LuaUi::Layer::count()) 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 layersMeta = layers[sol::metatable_key]; @@ -285,7 +287,7 @@ namespace MWLua return res; }; 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); }); };