From 3304e1e517fb8aac008c4684e72a4b59b408414a Mon Sep 17 00:00:00 2001 From: Kahrl Date: Tue, 25 Aug 2015 07:44:53 +0200 Subject: Push error handler afresh each time lua_pcall is used Fixes "double fault" / "error in error handling" messages (issue #1423) and instead shows a complete backtrace. --- src/script/cpp_api/s_entity.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src/script/cpp_api/s_entity.cpp') diff --git a/src/script/cpp_api/s_entity.cpp b/src/script/cpp_api/s_entity.cpp index 0d159846a..378a6bf09 100644 --- a/src/script/cpp_api/s_entity.cpp +++ b/src/script/cpp_api/s_entity.cpp @@ -80,6 +80,8 @@ void ScriptApiEntity::luaentity_Activate(u16 id, verbosestream << "scriptapi_luaentity_activate: id=" << id << std::endl; + int error_handler = PUSH_ERROR_HANDLER(L); + // Get core.luaentities[id] luaentity_get(L, id); int object = lua_gettop(L); @@ -93,11 +95,11 @@ void ScriptApiEntity::luaentity_Activate(u16 id, lua_pushinteger(L, dtime_s); setOriginFromTable(object); - PCALL_RES(lua_pcall(L, 3, 0, m_errorhandler)); + PCALL_RES(lua_pcall(L, 3, 0, error_handler)); } else { lua_pop(L, 1); } - lua_pop(L, 1); // Pop object + lua_pop(L, 2); // Pop object and error handler } void ScriptApiEntity::luaentity_Remove(u16 id) @@ -126,6 +128,8 @@ std::string ScriptApiEntity::luaentity_GetStaticdata(u16 id) //infostream<<"scriptapi_luaentity_get_staticdata: id="<