Merge pull request #62 from Indev450/fix-lua-onchange-error-in-error-handling

Fix 'error in error handling' for cases when error happens in cvar.fu…
This commit was merged in pull request #62.
This commit is contained in:
indev authored and GitHub committed 2023-09-13 21:16:54 +03:00
commit e1b41d2c58
1 file changed
+3 -1
+3 -1
View File
@@ -293,6 +293,8 @@ static void Lua_OnChange(void)
//lua_settop(gL, 0); // Just in case...
lua_pushcfunction(gL, LUA_GetErrorMessage);
int error_handler_i = abs_index(gL, -1);
// From CV_OnChange registry field, get the function for this cvar by name.
lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange");
I_Assert(lua_istable(gL, -1));
@@ -304,7 +306,7 @@ static void Lua_OnChange(void)
lua_getfield(gL, -1, cvname); // get consvar_t* userdata.
lua_remove(gL, -2); // pop the CV_Vars table.
LUA_Call(gL, 1, 0, 1); // call function(cvar)
LUA_Call(gL, 1, 0, error_handler_i); // call function(cvar)
lua_pop(gL, 2); // pop CV_OnChange table and error handler
}