summaryrefslogtreecommitdiff
path: root/src/config/lua/LuaEventHandler.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-05-01 23:50:57 +0100
committerGitHub <noreply@github.com>2026-05-01 23:50:57 +0100
commitc7b8fe13c10d6a4392bfda9bcfc041e0ea0b7c00 (patch)
treeb305320b07c3f603ae37b19a64c34066fe848443 /src/config/lua/LuaEventHandler.cpp
parent6e1fcfa81e55a7d78e40fdb5c41700c18b0e1268 (diff)
tests: fix gtests crashing (#14244)
Diffstat (limited to 'src/config/lua/LuaEventHandler.cpp')
-rw-r--r--src/config/lua/LuaEventHandler.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/config/lua/LuaEventHandler.cpp b/src/config/lua/LuaEventHandler.cpp
index eb4f6bc5..fbb44dac 100644
--- a/src/config/lua/LuaEventHandler.cpp
+++ b/src/config/lua/LuaEventHandler.cpp
@@ -61,15 +61,18 @@ void CLuaEventHandler::dispatch(const std::string& name, int nargs, const std::f
lua_rawgeti(m_lua, LUA_REGISTRYINDEX, sub->second.luaRef);
pushArgs();
- int status = LUA_OK;
- if (auto* mgr = CConfigManager::fromLuaState(m_lua); mgr)
+ auto* mgr = CConfigManager::fromLuaState(m_lua);
+
+ int status = LUA_OK;
+ if (mgr)
status = mgr->guardedPCall(nargs, 0, 0, CConfigManager::LUA_TIMEOUT_EVENT_CALLBACK_MS, std::format("hl.on(\"{}\") callback", name));
else
status = lua_pcall(m_lua, nargs, 0, 0);
if (status != LUA_OK) {
const char* err = lua_tostring(m_lua, -1);
- Config::Lua::mgr()->addError(std::format("hl.on(\"{}\") callback: {}", name, err ? err : "(unknown)"));
+ if (mgr)
+ mgr->addError(std::format("hl.on(\"{}\") callback: {}", name, err ? err : "(unknown)"));
lua_pop(m_lua, 1);
}
}