forked from mirrors/0ad
Store the ScriptInterface& in ModuleLoader::Result
During hotloading the `ScriptRequest` was constructed from a `JSContext*`. That requires that already an other `ScriptRequest` is active. Which isn't always the case. Now The `ScriptRequest` is constructed from a `ScriptInterface&`. Storing a `ScriptInterface&` in the `ModuleLoader::Result` allows to remove the `m_Result` as it is retrieved from the `ScriptInterface`.
This commit is contained in:
@@ -421,17 +421,17 @@ ModuleLoader::Result::iterator& ModuleLoader::Result::iterator::operator++(int)
|
||||
}
|
||||
|
||||
ModuleLoader::Result::Result(const ScriptRequest& rq, const VfsPath& modulePath):
|
||||
m_Cx{rq.cx},
|
||||
m_Loader{rq.GetScriptInterface().GetModuleLoader()},
|
||||
m_Script{rq.GetScriptInterface()},
|
||||
m_ModulePath{modulePath},
|
||||
m_Storage{rq, m_Loader, *this, m_ModulePath}
|
||||
m_Storage{rq, m_Script.GetModuleLoader(), *this, m_ModulePath}
|
||||
{
|
||||
}
|
||||
|
||||
ModuleLoader::Result::~Result()
|
||||
{
|
||||
const auto modIter = m_Loader.m_Registry.find(m_ModulePath);
|
||||
if (modIter == m_Loader.m_Registry.end())
|
||||
ModuleLoader::RegistryType& registry{m_Script.GetModuleLoader().m_Registry};
|
||||
const auto modIter = registry.find(m_ModulePath);
|
||||
if (modIter == registry.end())
|
||||
return;
|
||||
|
||||
std::get<1>(*modIter).RemoveRequester(this);
|
||||
@@ -450,7 +450,7 @@ ModuleLoader::Result::~Result()
|
||||
void ModuleLoader::Result::Resume()
|
||||
{
|
||||
if (m_Storage.IsWaiting())
|
||||
m_Storage = ModuleLoader::Future{m_Cx, m_Loader, *this, m_ModulePath};
|
||||
m_Storage = ModuleLoader::Future{m_Script, m_Script.GetModuleLoader(), *this, m_ModulePath};
|
||||
}
|
||||
|
||||
ModuleLoader::ModuleLoader(ModuleLoader::AllowModuleFunc allowModule):
|
||||
|
||||
Reference in New Issue
Block a user