diff --git a/aegisub/src/auto4_lua.cpp b/aegisub/src/auto4_lua.cpp index b5f76fbe6..17cab26fe 100644 --- a/aegisub/src/auto4_lua.cpp +++ b/aegisub/src/auto4_lua.cpp @@ -66,6 +66,7 @@ #include #include #include +#include #include #include @@ -712,7 +713,12 @@ namespace Automation4 { // LuaFeatureMacro int LuaCommand::LuaRegister(lua_State *L) { - cmd::reg(agi::util::make_unique(L)); + static std::mutex mutex; + auto command = agi::util::make_unique(L); + { + std::lock_guard lock(mutex); + cmd::reg(std::move(command)); + } return 0; } @@ -955,7 +961,12 @@ namespace Automation4 { int LuaExportFilter::LuaRegister(lua_State *L) { - AssExportFilterChain::Register(agi::util::make_unique(L)); + static std::mutex mutex; + auto filter = agi::util::make_unique(L); + { + std::lock_guard lock(mutex); + AssExportFilterChain::Register(std::move(filter)); + } return 0; }