1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-06 07:15:36 +00:00

Merge branch 'roundinguicornerssaveseyes' into 'master'

Don't assume execution of an internal Lua script can't fail

Closes #7627

See merge request OpenMW/openmw!4190
This commit is contained in:
psi29a 2024-06-22 16:34:13 +00:00
commit e88cbf86a4
2 changed files with 4 additions and 3 deletions

View file

@ -116,8 +116,9 @@ namespace LuaUtil
static void disableProfiler() { sProfilerEnabled = false; }
static bool isProfilerEnabled() { return sProfilerEnabled; }
private:
static sol::protected_function_result throwIfError(sol::protected_function_result&&);
private:
template <typename... Args>
friend sol::protected_function_result call(const sol::protected_function& fn, Args&&... args);
template <typename... Args>

View file

@ -5,9 +5,9 @@ namespace LuaUi
{
sol::protected_function loadContentConstructor(LuaUtil::LuaState* state)
{
sol::function loader = state->loadInternalLib("content");
sol::protected_function loader = state->loadInternalLib("content");
sol::set_environment(state->newInternalLibEnvironment(), loader);
sol::table metatable = loader().get<sol::table>();
sol::table metatable = LuaUtil::LuaState::throwIfError(loader()).get<sol::table>();
if (metatable["new"].get_type() != sol::type::function)
throw std::logic_error("Expected function");
return metatable["new"].get<sol::protected_function>();