From 69c85e5169e5322857d2dfbfccd45281ca1be1c4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 4 Feb 2014 10:29:10 +0100 Subject: Fixed error handling in cPluginManager:CallPlugin() API. Fixed: When the called function malfunctioned, the entire plugin's call was aborted. --- src/Bindings/LuaState.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 6a02197e8..0a3f6f5b7 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1072,7 +1072,8 @@ int cLuaState::CallFunctionWithForeignParams( } // Call the function, with an error handler: - int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop); + LogStack("Before pcall"); + int s = lua_pcall(m_LuaState, a_SrcParamEnd - a_SrcParamStart + 1, LUA_MULTRET, OldTop + 1); if (ReportErrors(s)) { LOGWARN("Error while calling function '%s' in '%s'", a_FunctionName.c_str(), m_SubsystemName.c_str()); @@ -1088,7 +1089,9 @@ int cLuaState::CallFunctionWithForeignParams( m_NumCurrentFunctionArgs = -1; m_CurrentFunctionName.clear(); - return -1; + // Make Lua think everything is okay and return 0 values, so that plugins continue executing. + // The failure is indicated by the zero return values. + return 0; } // Reset the internal checking mechanisms: -- cgit v1.2.3