Fix crash when cancelling automation scripts
When cancelling an automation macro from the progress dialog, the dialog throws a UserCancelException. If the macro still runs to the end afterwards (instead of calling aegisub.cancel or causing an exception), the two return values are left on the stack. This causes assertion errors due to check_stack when those are enabled.
This commit is contained in:
parent
5a0bfdd775
commit
a394aefd1a
1 changed files with 23 additions and 17 deletions
|
@ -624,6 +624,7 @@ namespace {
|
|||
{
|
||||
bool failed = false;
|
||||
BackgroundScriptRunner bsr(parent, title);
|
||||
try {
|
||||
bsr.Run([&](ProgressSink *ps) {
|
||||
LuaProgressSink lps(L, ps, can_open_config);
|
||||
|
||||
|
@ -645,6 +646,11 @@ namespace {
|
|||
|
||||
lua_gc(L, LUA_GCCOLLECT, 0);
|
||||
});
|
||||
} catch (agi::UserCancelException const&) {
|
||||
if (!failed)
|
||||
lua_pop(L, 2);
|
||||
throw;
|
||||
}
|
||||
if (failed)
|
||||
throw agi::UserCancelException("Script threw an error");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue