From e9d72ad7ed7d6897a3807b1293ff4c37c6c5b7d9 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Wed, 19 Oct 2016 20:56:51 -0400 Subject: [PATCH] partially revert 797613f760d0c84afefa39b305bb512f4a574479 attempts to fix bug reported by tad_carlucci discussed on #wesnoth-dev 10-19-2016 --- src/scripting/lua_common.cpp | 8 ++------ src/scripting/lua_common.hpp | 5 +++++ src/scripting/lua_kernel_base.cpp | 4 ---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/scripting/lua_common.cpp b/src/scripting/lua_common.cpp index d1a9166c2d03..89775ef78851 100644 --- a/src/scripting/lua_common.cpp +++ b/src/scripting/lua_common.cpp @@ -922,10 +922,6 @@ void chat_message(std::string const &caption, std::string const &msg) events::chat_handler::MESSAGE_PUBLIC, false); } -// To silence "no prototype" warnings -void push_error_handler(lua_State *L); -int luaW_pcall_internal(lua_State *L, int nArgs, int nRets); - void push_error_handler(lua_State *L) { luaW_getglobal(L, "debug", "traceback"); @@ -943,11 +939,11 @@ int luaW_pcall_internal(lua_State *L, int nArgs, int nRets) // Call the function. int errcode = lua_pcall(L, nArgs, nRets, -2 - nArgs); + tlua_jailbreak_exception::rethrow(); + // Remove the error handler. lua_remove(L, error_handler_index); - tlua_jailbreak_exception::rethrow(); - return errcode; } diff --git a/src/scripting/lua_common.hpp b/src/scripting/lua_common.hpp index 899c89d4ca73..84859a1ffff1 100644 --- a/src/scripting/lua_common.hpp +++ b/src/scripting/lua_common.hpp @@ -179,6 +179,11 @@ void chat_message(std::string const &caption, std::string const &msg); */ bool luaW_pcall(lua_State *L, int nArgs, int nRets, bool allow_wml_error = false); +// Don't use these directly +void push_error_handler(lua_State *L); +int luaW_pcall_internal(lua_State *L, int nArgs, int nRets); + + int luaW_type_error (lua_State *L, int narg, const char *tname); #define return_tstring_attrib(name, accessor) \ diff --git a/src/scripting/lua_kernel_base.cpp b/src/scripting/lua_kernel_base.cpp index 56b91e6960e1..93df7a471ac8 100644 --- a/src/scripting/lua_kernel_base.cpp +++ b/src/scripting/lua_kernel_base.cpp @@ -223,8 +223,6 @@ int dispatch(lua_State *L) { return ((lua_kernel_base::get_lua_kernel(L)).*method)(L); } -extern void push_error_handler(lua_State *L); - // Ctor, initialization lua_kernel_base::lua_kernel_base() : mState(luaL_newstate()) @@ -458,8 +456,6 @@ bool lua_kernel_base::protected_call(int nArgs, int nRets, error_handler e_h) return this->protected_call(mState, nArgs, nRets, e_h); } -extern int luaW_pcall_internal(lua_State *L, int nArgs, int nRets); - bool lua_kernel_base::protected_call(lua_State * L, int nArgs, int nRets, error_handler e_h) { int errcode = luaW_pcall_internal(L, nArgs, nRets);