diff --git a/components/lua/luastate.hpp b/components/lua/luastate.hpp index 509b5e16e1..8430586d89 100644 --- a/components/lua/luastate.hpp +++ b/components/lua/luastate.hpp @@ -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 friend sol::protected_function_result call(const sol::protected_function& fn, Args&&... args); template diff --git a/components/lua_ui/content.cpp b/components/lua_ui/content.cpp index dd169a9291..101cfc75d1 100644 --- a/components/lua_ui/content.cpp +++ b/components/lua_ui/content.cpp @@ -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 metatable = LuaUtil::LuaState::throwIfError(loader()).get(); if (metatable["new"].get_type() != sol::type::function) throw std::logic_error("Expected function"); return metatable["new"].get();