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
pull/3236/head
psi29a 6 months ago
commit e88cbf86a4

@ -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>

@ -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>();

Loading…
Cancel
Save