mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 14:54:33 +00:00
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();
|
return json::object();
|
||||||
};
|
};
|
||||||
m_requests["/clear_test_state"] = [this](const json dict) {
|
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.
|
||||||
// The session ID points to the Realm constructor object, which should remain.
|
auto realm_constructor = m_objects[m_session_id];
|
||||||
if (object.first != m_session_id) {
|
m_objects.clear();
|
||||||
m_objects.erase(object.first);
|
|
||||||
}
|
if (realm_constructor) {
|
||||||
|
m_objects.emplace(m_session_id, realm_constructor);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_callbacks.clear();
|
m_callbacks.clear();
|
||||||
JSGarbageCollect(m_context);
|
JSGarbageCollect(m_context);
|
||||||
js::delete_all_realms();
|
js::delete_all_realms();
|
||||||
|
|
||||||
return json::object();
|
return json::object();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user