diff options
author | Kahrl <kahrl@gmx.net> | 2015-08-25 07:44:53 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-08-27 01:56:06 +0200 |
commit | 3304e1e517fb8aac008c4684e72a4b59b408414a (patch) | |
tree | ddcc820601c02d6783578b7accc68d35a2d312fc /src/script/cpp_api/s_mainmenu.cpp | |
parent | 8658c8d9b5f30dc952eed29a19d619de9210474c (diff) | |
download | minetest-3304e1e517fb8aac008c4684e72a4b59b408414a.tar.gz minetest-3304e1e517fb8aac008c4684e72a4b59b408414a.tar.bz2 minetest-3304e1e517fb8aac008c4684e72a4b59b408414a.zip |
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.
Diffstat (limited to 'src/script/cpp_api/s_mainmenu.cpp')
-rw-r--r-- | src/script/cpp_api/s_mainmenu.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/script/cpp_api/s_mainmenu.cpp b/src/script/cpp_api/s_mainmenu.cpp index 17ceff082..e9a7a13b9 100644 --- a/src/script/cpp_api/s_mainmenu.cpp +++ b/src/script/cpp_api/s_mainmenu.cpp @@ -43,6 +43,8 @@ void ScriptApiMainMenu::handleMainMenuEvent(std::string text) { SCRIPTAPI_PRECHECKHEADER + int error_handler = PUSH_ERROR_HANDLER(L); + // Get handler function lua_getglobal(L, "core"); lua_getfield(L, -1, "event_handler"); @@ -55,13 +57,16 @@ void ScriptApiMainMenu::handleMainMenuEvent(std::string text) // Call it lua_pushstring(L, text.c_str()); - PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler)); + PCALL_RES(lua_pcall(L, 1, 0, error_handler)); + lua_pop(L, 1); // Pop error handler } void ScriptApiMainMenu::handleMainMenuButtons(const StringMap &fields) { SCRIPTAPI_PRECHECKHEADER + int error_handler = PUSH_ERROR_HANDLER(L); + // Get handler function lua_getglobal(L, "core"); lua_getfield(L, -1, "button_handler"); @@ -84,6 +89,7 @@ void ScriptApiMainMenu::handleMainMenuButtons(const StringMap &fields) } // Call it - PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler)); + PCALL_RES(lua_pcall(L, 1, 0, error_handler)); + lua_pop(L, 1); // Pop error handler } |