lua: Don't check_stack in LuaCheckStack destructor

This would cause an assertion failure in functions like lua_for_each
when the given closure throws an error and thus leaves some  values on
the stack. This can make Aegisub crash entirely instead of just catching
and reporting the error. Instead, these stack_checks can be done
manually.
This commit is contained in:
arch1t3cht 2023-05-22 09:11:46 +02:00
parent 79050dfdfb
commit 42f7e53e92
2 changed files with 2 additions and 1 deletions

View File

@ -129,7 +129,6 @@ struct LuaStackcheck {
void dump();
LuaStackcheck(lua_State *L) : L(L), startstack(lua_gettop(L)) { }
~LuaStackcheck() { check_stack(0); }
};
#else
struct LuaStackcheck {

View File

@ -680,6 +680,7 @@ namespace {
if (lua_isnumber(L, -1) && lua_tointeger(L, -1) == 3) {
lua_pop(L, 1); // just to avoid tripping the stackcheck in debug
description = "Attempted to load an Automation 3 script as an Automation 4 Lua script. Automation 3 is no longer supported.";
stackcheck.check_stack(0);
return;
}
@ -692,6 +693,7 @@ namespace {
name = GetPrettyFilename().string();
lua_pop(L, 1);
stackcheck.check_stack(0);
// if we got this far, the script should be ready
loaded = true;
}