forked from mia/Aegisub
Fix an occasional crash when loading Automation scripts
cmd::reg and AssExportFilterChain::Register are not thread-safe, so guard them with a mutex.
This commit is contained in:
parent
f1ed0e4313
commit
ec7d75d1ae
1 changed files with 13 additions and 2 deletions
|
@ -66,6 +66,7 @@
|
||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#include <wx/clipbrd.h>
|
#include <wx/clipbrd.h>
|
||||||
#include <wx/filefn.h>
|
#include <wx/filefn.h>
|
||||||
|
@ -712,7 +713,12 @@ namespace Automation4 {
|
||||||
// LuaFeatureMacro
|
// LuaFeatureMacro
|
||||||
int LuaCommand::LuaRegister(lua_State *L)
|
int LuaCommand::LuaRegister(lua_State *L)
|
||||||
{
|
{
|
||||||
cmd::reg(agi::util::make_unique<LuaCommand>(L));
|
static std::mutex mutex;
|
||||||
|
auto command = agi::util::make_unique<LuaCommand>(L);
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
cmd::reg(std::move(command));
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -955,7 +961,12 @@ namespace Automation4 {
|
||||||
|
|
||||||
int LuaExportFilter::LuaRegister(lua_State *L)
|
int LuaExportFilter::LuaRegister(lua_State *L)
|
||||||
{
|
{
|
||||||
AssExportFilterChain::Register(agi::util::make_unique<LuaExportFilter>(L));
|
static std::mutex mutex;
|
||||||
|
auto filter = agi::util::make_unique<LuaExportFilter>(L);
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
AssExportFilterChain::Register(std::move(filter));
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue