forked from 0ad/0ad
Fixes small memory leak introduced in 28bdd8540f
.
Thanks to leper for pointing it out. This was SVN commit r15569.
This commit is contained in:
parent
28bdd8540f
commit
64efbfeae3
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1207,8 +1207,8 @@ bool Autostart(const CmdLineArgs& args)
|
|||||||
mapSize = size.ToUInt();
|
mapSize = size.ToUInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptInterface.SetProperty(settings, "Seed", seed); // Random seed
|
scriptInterface.SetProperty(settings, "Seed", seed); // Random seed
|
||||||
scriptInterface.SetProperty(settings, "Size", mapSize); // Random map size (in patches)
|
scriptInterface.SetProperty(settings, "Size", mapSize); // Random map size (in patches)
|
||||||
|
|
||||||
// Get optional number of players (default 2)
|
// Get optional number of players (default 2)
|
||||||
size_t numPlayers = 2;
|
size_t numPlayers = 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user