Fix crash when a Lua tool Perform callback throws an error

Broken since 00ec4e0754, when the Perform callback was added. It's a bad idea to pop return values that never got pushed because the function that was supposed to push them threw an error.
This commit is contained in:
Tamás Bálint Misius
2024-11-20 20:42:11 +01:00
parent 0c74c8080d
commit b448622921

View File

@@ -91,11 +91,14 @@ static int luaPerformWrapper(SimTool *tool, Simulation *sim, Particle *cpart, in
lsi->Log(CommandInterface::LogError, "In perform func: " + LuaGetError());
lua_pop(L, 1);
}
if (lua_isboolean(L, -1))
else
{
ok = lua_toboolean(L, -1);
if (lua_isboolean(L, -1))
{
ok = lua_toboolean(L, -1);
}
lua_pop(L, 1);
}
lua_pop(L, 1);
}
return ok;
}