From f41d4fa48e2147efa25eed698cd5d8cdb25957f6 Mon Sep 17 00:00:00 2001 From: Yves Date: Sat, 26 Jul 2014 10:58:24 +0000 Subject: [PATCH] Fixes compartment mismatch introduced in a5ebd8dafd. Also modifies some related functions to use SpiderMonkey stack rooting types instead of CScriptValRooted. Refs #2415 This was SVN commit r15561. --- source/simulation2/Simulation2.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/source/simulation2/Simulation2.cpp b/source/simulation2/Simulation2.cpp index 7c9c936ea4..0cb8469bc2 100644 --- a/source/simulation2/Simulation2.cpp +++ b/source/simulation2/Simulation2.cpp @@ -101,7 +101,7 @@ public: static bool LoadDefaultScripts(CComponentManager& componentManager, std::set* loadedScripts); static bool LoadScripts(CComponentManager& componentManager, std::set* loadedScripts, const VfsPath& path); - static bool LoadTriggerScripts(CComponentManager& componentManager, const CScriptValRooted& mapSettings); + static bool LoadTriggerScripts(CComponentManager& componentManager, JS::HandleValue mapSettings); Status ReloadChangedFile(const VfsPath& path); static Status ReloadChangedFileCB(void* param, const VfsPath& path) @@ -190,13 +190,13 @@ bool CSimulation2Impl::LoadScripts(CComponentManager& componentManager, std::set return ok; } -bool CSimulation2Impl::LoadTriggerScripts(CComponentManager& componentManager, const CScriptValRooted& mapSettings) +bool CSimulation2Impl::LoadTriggerScripts(CComponentManager& componentManager, JS::HandleValue mapSettings) { bool ok = true; - if (componentManager.GetScriptInterface().HasProperty(mapSettings.get(), "TriggerScripts")) + if (componentManager.GetScriptInterface().HasProperty(mapSettings, "TriggerScripts")) { std::vector scriptNames; - componentManager.GetScriptInterface().GetProperty(mapSettings.get(), "TriggerScripts", scriptNames); + componentManager.GetScriptInterface().GetProperty(mapSettings, "TriggerScripts", scriptNames); for (u32 i = 0; i < scriptNames.size(); ++i) { std::string scriptName = "maps/" + scriptNames[i]; @@ -355,7 +355,12 @@ void CSimulation2Impl::Update(int turnLength, const std::vectorm_MapSettings.get()); // TODO: Check if this temporary root can be removed after SpiderMonkey 31 upgrade + // Initialize here instead of in Update() GetScriptInterface().CallFunctionVoid(GetScriptInterface().GetGlobalObject(), "LoadMapSettings", m->m_MapSettings); @@ -726,7 +736,7 @@ void CSimulation2::LoadMapSettings() GetScriptInterface().LoadScript(L"map startup script", m->m_StartupScript); // Load the trigger scripts after we have loaded the simulation and the map. - m->LoadTriggerScripts(m->m_ComponentManager, m->m_MapSettings); + m->LoadTriggerScripts(m->m_ComponentManager, tmpMapSettings); } int CSimulation2::ProgressiveLoad()