Fix for consecutive calls to clearTestState()
This bug would only happen from Chrome debug mode, where consecutive calls would crash the app because the m_objects iterator would be in a bad state. This method is faster anyways.
This commit is contained in:
parent
af70bb3c63
commit
5a3997d268
13
src/rpc.cpp
13
src/rpc.cpp
|
@ -182,15 +182,18 @@ RPCServer::RPCServer() {
|
|||
return json::object();
|
||||
};
|
||||
m_requests["/clear_test_state"] = [this](const json dict) {
|
||||
for (auto object : m_objects) {
|
||||
// The session ID points to the Realm constructor object, which should remain.
|
||||
if (object.first != m_session_id) {
|
||||
m_objects.erase(object.first);
|
||||
}
|
||||
// The session ID points to the Realm constructor object, which should remain.
|
||||
auto realm_constructor = m_objects[m_session_id];
|
||||
m_objects.clear();
|
||||
|
||||
if (realm_constructor) {
|
||||
m_objects.emplace(m_session_id, realm_constructor);
|
||||
}
|
||||
|
||||
m_callbacks.clear();
|
||||
JSGarbageCollect(m_context);
|
||||
js::delete_all_realms();
|
||||
|
||||
return json::object();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue