mirror of
https://github.com/lubosz/overte.git
synced 2025-04-07 09:22:42 +02:00
Replaced mutex locking with lock guard
This commit is contained in:
parent
7481130e61
commit
6645763117
1 changed files with 7 additions and 8 deletions
|
@ -2553,13 +2553,12 @@ bool EntityTree::writeToMap(QVariantMap& entityDescription, OctreeElementPointer
|
|||
}
|
||||
entityDescription["DataVersion"] = _persistDataVersion;
|
||||
entityDescription["Id"] = _persistID;
|
||||
scriptEngineMutex.lock();
|
||||
const std::lock_guard<std::mutex> scriptLock(scriptEngineMutex);
|
||||
RecurseOctreeToMapOperator theOperator(entityDescription, element, scriptEngine.get(), skipDefaultValues,
|
||||
skipThoseWithBadParents, _myAvatar);
|
||||
withReadLock([&] {
|
||||
recurseTreeWithOperator(&theOperator);
|
||||
});
|
||||
scriptEngineMutex.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2728,11 +2727,12 @@ bool EntityTree::readFromMap(QVariantMap& map, const bool isImport) {
|
|||
" mapped it to parentJointIndex " << entityMap["parentJointIndex"].toInt();
|
||||
}
|
||||
|
||||
scriptEngineMutex.lock();
|
||||
ScriptValue entityScriptValue = variantMapToScriptValue(entityMap, *scriptEngine);
|
||||
EntityItemProperties properties;
|
||||
EntityItemPropertiesFromScriptValueIgnoreReadOnly(entityScriptValue, properties);
|
||||
scriptEngineMutex.unlock();
|
||||
{
|
||||
const std::lock_guard<std::mutex> scriptLock(scriptEngineMutex);
|
||||
ScriptValue entityScriptValue = variantMapToScriptValue(entityMap, *scriptEngine);
|
||||
EntityItemPropertiesFromScriptValueIgnoreReadOnly(entityScriptValue, properties);
|
||||
}
|
||||
|
||||
EntityItemID entityItemID;
|
||||
if (entityMap.contains("id")) {
|
||||
|
@ -2881,12 +2881,11 @@ bool EntityTree::readFromMap(QVariantMap& map, const bool isImport) {
|
|||
}
|
||||
|
||||
bool EntityTree::writeToJSON(QString& jsonString, const OctreeElementPointer& element) {
|
||||
scriptEngineMutex.lock();
|
||||
const std::lock_guard<std::mutex> scriptLock(scriptEngineMutex);
|
||||
RecurseOctreeToJSONOperator theOperator(element, scriptEngine.get(), jsonString);
|
||||
withReadLock([&] {
|
||||
recurseTreeWithOperator(&theOperator);
|
||||
});
|
||||
scriptEngineMutex.unlock();
|
||||
|
||||
jsonString = theOperator.getJson();
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue