From 9605e0fcb90e7087891c57ee3d65e151788c2877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Sun, 15 Oct 2023 11:29:51 +0200 Subject: [PATCH] Fix spurious timeout errors from some callbacks Mainly the new ones I added >_> Don't use lua_pcall, kids. tpt_lua_pcall records when control flow was "last seen" on the C++ side, so you have to call it rather than just lua_pcall if you want to avoid timeout ("script not responding") errors. For the record, I had a really hard time reproducing these errors. I had to tune the timeout to such a low value that the errors might as well have not been spurious, i.e. not much could have been done in such a short period of time anyway, bugs or no bugs. --- src/lua/LuaScriptInterface.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index b16be178f..d43c3f594 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -708,7 +708,7 @@ static int beginMessageBox(lua_State* l) cb->Push(l); if (lua_isfunction(l, -1)) { - if (lua_pcall(l, 0, 0, 0)) + if (tpt_lua_pcall(l, 0, 0, 0, false)) { luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); } @@ -732,7 +732,7 @@ static int beginThrowError(lua_State* l) cb->Push(l); if (lua_isfunction(l, -1)) { - if (lua_pcall(l, 0, 0, 0)) + if (tpt_lua_pcall(l, 0, 0, 0, false)) { luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); } @@ -767,7 +767,7 @@ static int beginInput(lua_State* l) { lua_pushnil(l); } - if (lua_pcall(l, 1, 0, 0)) + if (tpt_lua_pcall(l, 1, 0, 0, false)) { luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); } @@ -799,7 +799,7 @@ static int beginConfirm(lua_State *l) if (lua_isfunction(l, -1)) { lua_pushboolean(l, result); - if (lua_pcall(l, 1, 0, 0)) + if (tpt_lua_pcall(l, 1, 0, 0, false)) { luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); } @@ -5181,7 +5181,7 @@ int LuaScriptInterface::luatpt_getscript(lua_State* l) tpt_lua_pushString(l, runFailed->error); nargs = 2; } - if (lua_pcall(l, nargs, 0, 0)) + if (tpt_lua_pcall(l, nargs, 0, 0, false)) { luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); }