Enable lua stack checking in debug builds

Originally committed to SVN as r6465.
This commit is contained in:
Thomas Goyne 2012-02-10 02:16:49 +00:00
parent 3fd457ac68
commit 952bc02c07

View file

@ -137,7 +137,7 @@ namespace {
} }
// LuaStackcheck // LuaStackcheck
#if 0 #ifdef _DEBUG
struct LuaStackcheck { struct LuaStackcheck {
lua_State *L; lua_State *L;
int startstack; int startstack;
@ -768,15 +768,18 @@ namespace Automation4 {
} }
catch (agi::UserCancelException const&) { catch (agi::UserCancelException const&) {
subsobj->Cancel(); subsobj->Cancel();
stackcheck.check_stack(0);
} }
stackcheck.check_stack(0);
} }
bool LuaCommand::IsActive(const agi::Context *c) bool LuaCommand::IsActive(const agi::Context *c)
{ {
if (!(cmd_type & cmd::COMMAND_TOGGLE)) return false; if (!(cmd_type & cmd::COMMAND_TOGGLE)) return false;
LuaStackcheck stackcheck(L);
set_context(L, c); set_context(L, c);
stackcheck.check_stack(0);
GetFeatureFunction("isactive"); GetFeatureFunction("isactive");
LuaAssFile *subsobj = new LuaAssFile(L, c->ass); LuaAssFile *subsobj = new LuaAssFile(L, c->ass);
@ -792,6 +795,7 @@ namespace Automation4 {
result = !!lua_toboolean(L, -1); result = !!lua_toboolean(L, -1);
// clean up stack (result or error message) // clean up stack (result or error message)
stackcheck.check_stack(1);
lua_pop(L, 1); lua_pop(L, 1);
return result; return result;