Add missing JSAutoRequest calls. (hopefully all of them have been spotted now)
Patch by echotangoecho, refs #4053 This was SVN commit r18730.
This commit is contained in:
parent
184d64cdc8
commit
caef42084d
@ -117,6 +117,8 @@ void CGUIManager::PopPageCB(shared_ptr<ScriptInterface::StructuredClone> args)
|
|||||||
|
|
||||||
shared_ptr<ScriptInterface> scriptInterface = m_PageStack.back().gui->GetScriptInterface();
|
shared_ptr<ScriptInterface> scriptInterface = m_PageStack.back().gui->GetScriptInterface();
|
||||||
JSContext* cx = scriptInterface->GetContext();
|
JSContext* cx = scriptInterface->GetContext();
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
JS::RootedValue initDataVal(cx);
|
JS::RootedValue initDataVal(cx);
|
||||||
if (!initDataClone)
|
if (!initDataClone)
|
||||||
{
|
{
|
||||||
|
@ -292,7 +292,11 @@ void CNetTurnManager::AddCommand(int client, int player, JS::HandleValue data, u
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Simulation2.GetScriptInterface().FreezeObject(data, true);
|
m_Simulation2.GetScriptInterface().FreezeObject(data, true);
|
||||||
m_QueuedCommands[turn - (m_CurrentTurn+1)][client].emplace_back(player, m_Simulation2.GetScriptInterface().GetContext(), data);
|
|
||||||
|
JSContext* cx = m_Simulation2.GetScriptInterface().GetContext();
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
|
m_QueuedCommands[turn - (m_CurrentTurn+1)][client].emplace_back(player, cx, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetTurnManager::FinishedAllCommands(u32 turn, u32 turnLength)
|
void CNetTurnManager::FinishedAllCommands(u32 turn, u32 turnLength)
|
||||||
@ -556,10 +560,13 @@ void CNetReplayTurnManager::DoTurn(u32 turn)
|
|||||||
|
|
||||||
m_TurnLength = m_ReplayTurnLengths[turn];
|
m_TurnLength = m_ReplayTurnLengths[turn];
|
||||||
|
|
||||||
|
JSContext* cx = m_Simulation2.GetScriptInterface().GetContext();
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
// Simulate commands for that turn
|
// Simulate commands for that turn
|
||||||
for (const std::pair<player_id_t, std::string>& p : m_ReplayCommands[turn])
|
for (const std::pair<player_id_t, std::string>& p : m_ReplayCommands[turn])
|
||||||
{
|
{
|
||||||
JS::RootedValue command(m_Simulation2.GetScriptInterface().GetContext());
|
JS::RootedValue command(cx);
|
||||||
m_Simulation2.GetScriptInterface().ParseJSON(p.second, &command);
|
m_Simulation2.GetScriptInterface().ParseJSON(p.second, &command);
|
||||||
AddCommand(m_ClientId, p.first, command, m_CurrentTurn + 1);
|
AddCommand(m_ClientId, p.first, command, m_CurrentTurn + 1);
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,11 @@ bool CGame::StartVisualReplay(const std::string& replayPath)
|
|||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
std::getline(*m_ReplayStream, line);
|
std::getline(*m_ReplayStream, line);
|
||||||
JS::RootedValue attribs(scriptInterface.GetContext());
|
|
||||||
|
JSContext* cx = scriptInterface.GetContext();
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
|
JS::RootedValue attribs(cx);
|
||||||
scriptInterface.ParseJSON(line, &attribs);
|
scriptInterface.ParseJSON(line, &attribs);
|
||||||
StartGame(&attribs, "");
|
StartGame(&attribs, "");
|
||||||
|
|
||||||
|
@ -91,8 +91,11 @@ JS::Value JSI_VFS::BuildDirEntList(ScriptInterface::CxPrivate* pCxPrivate, const
|
|||||||
|
|
||||||
int flags = recurse ? vfs::DIR_RECURSIVE : 0;
|
int flags = recurse ? vfs::DIR_RECURSIVE : 0;
|
||||||
|
|
||||||
|
JSContext* cx = pCxPrivate->pScriptInterface->GetContext();
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
// build array in the callback function
|
// build array in the callback function
|
||||||
BuildDirEntListState state(pCxPrivate->pScriptInterface->GetContext());
|
BuildDirEntListState state(cx);
|
||||||
vfs::ForEachFile(g_VFS, path, BuildDirEntListCB, (uintptr_t)&state, filter, flags);
|
vfs::ForEachFile(g_VFS, path, BuildDirEntListCB, (uintptr_t)&state, filter, flags);
|
||||||
|
|
||||||
return OBJECT_TO_JSVAL(state.filename_array);
|
return OBJECT_TO_JSVAL(state.filename_array);
|
||||||
|
@ -298,6 +298,7 @@ public:
|
|||||||
ENSURE(pCxPrivate->pCBData);
|
ENSURE(pCxPrivate->pCBData);
|
||||||
CAIWorker* self = static_cast<CAIWorker*> (pCxPrivate->pCBData);
|
CAIWorker* self = static_cast<CAIWorker*> (pCxPrivate->pCBData);
|
||||||
JSContext* cx(self->m_ScriptInterface->GetContext());
|
JSContext* cx(self->m_ScriptInterface->GetContext());
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
CFixedVector2D pos, goalPos;
|
CFixedVector2D pos, goalPos;
|
||||||
std::vector<CFixedVector2D> waypoints;
|
std::vector<CFixedVector2D> waypoints;
|
||||||
@ -327,6 +328,7 @@ public:
|
|||||||
ENSURE(pCxPrivate->pCBData);
|
ENSURE(pCxPrivate->pCBData);
|
||||||
CAIWorker* self = static_cast<CAIWorker*> (pCxPrivate->pCBData);
|
CAIWorker* self = static_cast<CAIWorker*> (pCxPrivate->pCBData);
|
||||||
JSContext* cx(self->m_ScriptInterface->GetContext());
|
JSContext* cx(self->m_ScriptInterface->GetContext());
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
JS::RootedValue retVal(cx);
|
JS::RootedValue retVal(cx);
|
||||||
self->m_ScriptInterface->ToJSVal<Grid<u16> >(cx, &retVal, self->m_LongPathfinder.GetConnectivityGrid(passClass));
|
self->m_ScriptInterface->ToJSVal<Grid<u16> >(cx, &retVal, self->m_LongPathfinder.GetConnectivityGrid(passClass));
|
||||||
@ -521,6 +523,7 @@ public:
|
|||||||
|
|
||||||
m_GameState = gameState;
|
m_GameState = gameState;
|
||||||
JSContext* cx = m_ScriptInterface->GetContext();
|
JSContext* cx = m_ScriptInterface->GetContext();
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
if (dirtinessInformations.dirty)
|
if (dirtinessInformations.dirty)
|
||||||
{
|
{
|
||||||
@ -770,13 +773,17 @@ public:
|
|||||||
// Require unique prototype and name (for reverse lookup)
|
// Require unique prototype and name (for reverse lookup)
|
||||||
// TODO: this is yucky - see comment in Deserialize()
|
// TODO: this is yucky - see comment in Deserialize()
|
||||||
ENSURE(proto.isObject() && "A serializable prototype has to be an object!");
|
ENSURE(proto.isObject() && "A serializable prototype has to be an object!");
|
||||||
JS::RootedObject obj(m_ScriptInterface->GetContext(), &proto.toObject());
|
|
||||||
|
JSContext* cx = m_ScriptInterface->GetContext();
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
|
JS::RootedObject obj(cx, &proto.toObject());
|
||||||
if (m_SerializablePrototypes->has(obj) || m_DeserializablePrototypes.find(name) != m_DeserializablePrototypes.end())
|
if (m_SerializablePrototypes->has(obj) || m_DeserializablePrototypes.find(name) != m_DeserializablePrototypes.end())
|
||||||
{
|
{
|
||||||
LOGERROR("RegisterSerializablePrototype called with same prototype multiple times: p=%p n='%s'", (void *)obj.get(), utf8_from_wstring(name));
|
LOGERROR("RegisterSerializablePrototype called with same prototype multiple times: p=%p n='%s'", (void *)obj.get(), utf8_from_wstring(name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_SerializablePrototypes->add(m_ScriptInterface->GetContext(), obj, name);
|
m_SerializablePrototypes->add(cx, obj, name);
|
||||||
m_DeserializablePrototypes[name] = JS::Heap<JSObject*>(obj);
|
m_DeserializablePrototypes[name] = JS::Heap<JSObject*>(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +82,8 @@ public:
|
|||||||
virtual void PushLocalCommand(player_id_t player, JS::HandleValue cmd)
|
virtual void PushLocalCommand(player_id_t player, JS::HandleValue cmd)
|
||||||
{
|
{
|
||||||
JSContext* cx = GetSimContext().GetScriptInterface().GetContext();
|
JSContext* cx = GetSimContext().GetScriptInterface().GetContext();
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
m_LocalQueue.emplace_back(SimulationCommand(player, cx, cmd));
|
m_LocalQueue.emplace_back(SimulationCommand(player, cx, cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,7 +465,10 @@ u32 CBinarySerializerScriptImpl::GetScriptBackrefTag(JS::HandleObject obj)
|
|||||||
if (m_ScriptBackrefs.find(obj, tag))
|
if (m_ScriptBackrefs.find(obj, tag))
|
||||||
return tag;
|
return tag;
|
||||||
|
|
||||||
m_ScriptBackrefs.add(m_ScriptInterface.GetContext(), obj, m_ScriptBackrefsNext);
|
JSContext* cx = m_ScriptInterface.GetContext();
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
|
m_ScriptBackrefs.add(cx, obj, m_ScriptBackrefsNext);
|
||||||
|
|
||||||
m_ScriptBackrefsNext++;
|
m_ScriptBackrefsNext++;
|
||||||
// Return a non-tag number so callers know they need to serialize the object
|
// Return a non-tag number so callers know they need to serialize the object
|
||||||
|
@ -486,6 +486,9 @@ void CStdDeserializer::ScriptString(const char* name, JS::MutableHandleString ou
|
|||||||
#error TODO: probably need to convert JS strings from little-endian
|
#error TODO: probably need to convert JS strings from little-endian
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
JSContext* cx = m_ScriptInterface.GetContext();
|
||||||
|
JSAutoRequest rq(cx);
|
||||||
|
|
||||||
bool isLatin1;
|
bool isLatin1;
|
||||||
Bool("isLatin1", isLatin1);
|
Bool("isLatin1", isLatin1);
|
||||||
if (isLatin1)
|
if (isLatin1)
|
||||||
@ -493,7 +496,7 @@ void CStdDeserializer::ScriptString(const char* name, JS::MutableHandleString ou
|
|||||||
std::vector<JS::Latin1Char> str;
|
std::vector<JS::Latin1Char> str;
|
||||||
ReadStringLatin1(name, str);
|
ReadStringLatin1(name, str);
|
||||||
|
|
||||||
out.set(JS_NewStringCopyN(m_ScriptInterface.GetContext(), (const char*)str.data(), str.size()));
|
out.set(JS_NewStringCopyN(cx, (const char*)str.data(), str.size()));
|
||||||
if (!out)
|
if (!out)
|
||||||
throw PSERROR_Deserialize_ScriptError("JS_NewStringCopyN failed");
|
throw PSERROR_Deserialize_ScriptError("JS_NewStringCopyN failed");
|
||||||
}
|
}
|
||||||
@ -502,7 +505,7 @@ void CStdDeserializer::ScriptString(const char* name, JS::MutableHandleString ou
|
|||||||
utf16string str;
|
utf16string str;
|
||||||
ReadStringUTF16(name, str);
|
ReadStringUTF16(name, str);
|
||||||
|
|
||||||
out.set(JS_NewUCStringCopyN(m_ScriptInterface.GetContext(), (const char16_t*)str.data(), str.length()));
|
out.set(JS_NewUCStringCopyN(cx, (const char16_t*)str.data(), str.length()));
|
||||||
if (!out)
|
if (!out)
|
||||||
throw PSERROR_Deserialize_ScriptError("JS_NewUCStringCopyN failed");
|
throw PSERROR_Deserialize_ScriptError("JS_NewUCStringCopyN failed");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user