Fixes small memory leak introduced in 28bdd8540f.

Thanks to leper for pointing it out.

This was SVN commit r15569.
This commit is contained in:
Yves 2014-07-26 23:09:24 +00:00
parent 28bdd8540f
commit 64efbfeae3
2 changed files with 9 additions and 5 deletions

View File

@ -82,6 +82,13 @@ bool CMapGeneratorWorker::Run()
JSContext* cx = m_ScriptInterface->GetContext(); JSContext* cx = m_ScriptInterface->GetContext();
JSAutoRequest rq(cx); JSAutoRequest rq(cx);
// We must destroy the ScriptInterface in the same thread because the JSAPI requires that!
struct AutoFree {
AutoFree(ScriptInterface* p) : m_p(p) {}
~AutoFree() { SAFE_DELETE(m_p); }
ScriptInterface* m_p;
} autoFree(m_ScriptInterface);
m_ScriptInterface->SetCallbackData(static_cast<void*> (this)); m_ScriptInterface->SetCallbackData(static_cast<void*> (this));
// Replace RNG with a seeded deterministic function // Replace RNG with a seeded deterministic function
@ -132,9 +139,6 @@ bool CMapGeneratorWorker::Run()
return false; return false;
} }
// We must destroy the ScriptInterface in the same thread because the JSAPI requires that!
SAFE_DELETE(m_ScriptInterface);
return true; return true;
} }