Core/Scripting: Fix acquiring of references between script swaps

* Delay unloading of shared libraries to the next update tick
  to prevent crashes in the destructor of the last referenced
  script instance.
* Closes #17557
This commit is contained in:
Naios
2016-07-13 21:58:50 +02:00
parent d22569aaba
commit 445746c402
3 changed files with 55 additions and 14 deletions

View File

@@ -987,7 +987,7 @@ void ScriptMgr::Initialize()
FillSpellSummary();
// Load core scripts
SetScriptContext("___static___");
SetScriptContext(GetNameOfStaticContext());
// SmartAI
AddSC_SmartScripts();
@@ -1042,6 +1042,12 @@ void ScriptMgr::SwapScriptContext(bool initialize)
_currentContext.clear();
}
std::string const& ScriptMgr::GetNameOfStaticContext()
{
static std::string const name = "___static___";
return name;
}
void ScriptMgr::ReleaseScriptContext(std::string const& context)
{
sScriptRegistryCompositum->ReleaseContext(context);