From 952bc02c07ade198f820ba25f78d0f3e75f98019 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 10 Feb 2012 02:16:49 +0000 Subject: [PATCH] Enable lua stack checking in debug builds Originally committed to SVN as r6465. --- aegisub/src/auto4_lua.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/aegisub/src/auto4_lua.cpp b/aegisub/src/auto4_lua.cpp index 4274ba22e..8c99f9169 100644 --- a/aegisub/src/auto4_lua.cpp +++ b/aegisub/src/auto4_lua.cpp @@ -137,7 +137,7 @@ namespace { } // LuaStackcheck -#if 0 +#ifdef _DEBUG struct LuaStackcheck { lua_State *L; int startstack; @@ -768,15 +768,18 @@ namespace Automation4 { } catch (agi::UserCancelException const&) { subsobj->Cancel(); - stackcheck.check_stack(0); } + stackcheck.check_stack(0); } bool LuaCommand::IsActive(const agi::Context *c) { if (!(cmd_type & cmd::COMMAND_TOGGLE)) return false; + LuaStackcheck stackcheck(L); + set_context(L, c); + stackcheck.check_stack(0); GetFeatureFunction("isactive"); LuaAssFile *subsobj = new LuaAssFile(L, c->ass); @@ -792,6 +795,7 @@ namespace Automation4 { result = !!lua_toboolean(L, -1); // clean up stack (result or error message) + stackcheck.check_stack(1); lua_pop(L, 1); return result;