Fixed handling Lua errors in nested callbacks (#3755)

This commit is contained in:
Mattes D
2017-06-09 12:16:31 +02:00
committed by Lukas Pioch
parent 7922e6addb
commit 3c4e443ddc
4 changed files with 60 additions and 3 deletions
+6 -2
View File
@@ -1454,8 +1454,12 @@ bool cLuaState::CallFunction(int a_NumResults)
LOGWARNING("Error in %s calling function %s()", m_SubsystemName.c_str(), CurrentFunctionName.c_str());
// Remove the error handler and error message from the stack:
ASSERT(lua_gettop(m_LuaState) == 2);
lua_pop(m_LuaState, 2);
auto top = lua_gettop(m_LuaState);
if (top < 2)
{
LogStackValues(Printf("The Lua stack is in an unexpected state, expected at least two values there, but got %d", top).c_str());
}
lua_pop(m_LuaState, std::min(2, top));
return false;
}