1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-16 07:10:08 +00:00

Fix crash in LuaUtil::ScriptsContainer::~ScriptsContainer()

This commit is contained in:
Petr Mikheev 2021-09-30 02:59:38 +02:00
parent e24937df3b
commit 24ecdc37a7
2 changed files with 7 additions and 1 deletions

View File

@ -328,6 +328,12 @@ namespace LuaUtil
std::make_heap(mHoursTimersQueue.begin(), mHoursTimersQueue.end());
}
ScriptsContainer::~ScriptsContainer()
{
for (auto& [_, script] : mScripts)
script.mHiddenData[ScriptId::KEY] = sol::nil;
}
void ScriptsContainer::removeAllScripts()
{
for (auto& [_, script] : mScripts)

View File

@ -75,7 +75,7 @@ namespace LuaUtil
ScriptsContainer(LuaUtil::LuaState* lua, std::string_view namePrefix);
ScriptsContainer(const ScriptsContainer&) = delete;
ScriptsContainer(ScriptsContainer&&) = delete;
virtual ~ScriptsContainer() { removeAllScripts(); }
virtual ~ScriptsContainer();
// Adds package that will be available (via `require`) for all scripts in the container.
// Automatically applies LuaUtil::makeReadOnly to the package.