mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2024-12-28 18:18:52 +00:00
Don't assume execution of an internal Lua script can't fail
This commit is contained in:
parent
ca3f89045c
commit
5b82c7a95d
@ -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…
Reference in New Issue
Block a user