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.
This commit is contained in:
Tamás Bálint Misius 2023-10-15 11:29:51 +02:00
parent 8534be2bf9
commit 9605e0fcb9
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2

View File

@ -708,7 +708,7 @@ static int beginMessageBox(lua_State* l)
cb->Push(l); cb->Push(l);
if (lua_isfunction(l, -1)) 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()); luacon_ci->Log(CommandInterface::LogError, luacon_geterror());
} }
@ -732,7 +732,7 @@ static int beginThrowError(lua_State* l)
cb->Push(l); cb->Push(l);
if (lua_isfunction(l, -1)) 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()); luacon_ci->Log(CommandInterface::LogError, luacon_geterror());
} }
@ -767,7 +767,7 @@ static int beginInput(lua_State* l)
{ {
lua_pushnil(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()); luacon_ci->Log(CommandInterface::LogError, luacon_geterror());
} }
@ -799,7 +799,7 @@ static int beginConfirm(lua_State *l)
if (lua_isfunction(l, -1)) if (lua_isfunction(l, -1))
{ {
lua_pushboolean(l, result); 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()); luacon_ci->Log(CommandInterface::LogError, luacon_geterror());
} }
@ -5181,7 +5181,7 @@ int LuaScriptInterface::luatpt_getscript(lua_State* l)
tpt_lua_pushString(l, runFailed->error); tpt_lua_pushString(l, runFailed->error);
nargs = 2; 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()); luacon_ci->Log(CommandInterface::LogError, luacon_geterror());
} }