Skip to content

Commit

Permalink
Merge branch 'fix_crash' into 'master'
Browse files Browse the repository at this point in the history
Fix crash in LuaUtil::ScriptsContainer::~ScriptsContainer()

See merge request OpenMW/openmw!1252
  • Loading branch information
fr3dz10 committed Sep 30, 2021
2 parents e24937d + 24ecdc3 commit 5f3a36a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions components/lua/scriptscontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion components/lua/scriptscontainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5f3a36a

Please sign in to comment.