From f0cee09b7c303a3dc40865e7abb5ec39519a9b65 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Mon, 3 Mar 2025 19:36:54 +0100 Subject: [PATCH] Extend lifetime of strings placed on the action queue --- apps/openmw/mwlua/uibindings.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); }); };