mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 12:38:27 +02:00
make getJSONParameters thread-safe
This commit is contained in:
parent
916a7325bc
commit
33cde412b1
4 changed files with 11 additions and 4 deletions
|
@ -246,6 +246,7 @@ void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, const
|
||||||
if (entity && entity->shouldPreloadServerScript() && _entitiesScriptEngine) {
|
if (entity && entity->shouldPreloadServerScript() && _entitiesScriptEngine) {
|
||||||
QString scriptUrl = entity->getServerScripts();
|
QString scriptUrl = entity->getServerScripts();
|
||||||
scriptUrl = ResourceManager::normalizeURL(scriptUrl);
|
scriptUrl = ResourceManager::normalizeURL(scriptUrl);
|
||||||
|
qDebug() << "Loading entity server script" << scriptUrl << "for" << entityID;
|
||||||
ScriptEngine::loadEntityScript(_entitiesScriptEngine, entityID, scriptUrl, reload);
|
ScriptEngine::loadEntityScript(_entitiesScriptEngine, entityID, scriptUrl, reload);
|
||||||
entity->serverScriptHasPreloaded();
|
entity->serverScriptHasPreloaded();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2246,7 +2246,7 @@ bool EntityItem::matchesJSONFilters(const QJsonObject& jsonFilters) const {
|
||||||
|
|
||||||
static const QString SERVER_SCRIPTS_PROPERTY = "serverScripts";
|
static const QString SERVER_SCRIPTS_PROPERTY = "serverScripts";
|
||||||
|
|
||||||
for (auto& property : jsonFilters.keys()) {
|
foreach(const auto& property, jsonFilters.keys()) {
|
||||||
if (property == SERVER_SCRIPTS_PROPERTY && jsonFilters[property] == EntityQueryFilterSymbol::NonDefault) {
|
if (property == SERVER_SCRIPTS_PROPERTY && jsonFilters[property] == EntityQueryFilterSymbol::NonDefault) {
|
||||||
// check if this entity has a non-default value for serverScripts
|
// check if this entity has a non-default value for serverScripts
|
||||||
if (_serverScripts != ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS) {
|
if (_serverScripts != ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS) {
|
||||||
|
|
|
@ -132,7 +132,10 @@ int OctreeQuery::parseData(ReceivedMessage& message) {
|
||||||
sourceBuffer += binaryParametersBytes;
|
sourceBuffer += binaryParametersBytes;
|
||||||
|
|
||||||
// grab the parameter object from the packed binary representation of JSON
|
// grab the parameter object from the packed binary representation of JSON
|
||||||
_jsonParameters = QJsonDocument::fromBinaryData(binaryJSONParameters).object();
|
auto newJsonDocument = QJsonDocument::fromBinaryData(binaryJSONParameters);
|
||||||
|
|
||||||
|
QWriteLocker jsonParameterLocker { &_jsonParametersLock };
|
||||||
|
_jsonParameters = newJsonDocument.object();
|
||||||
}
|
}
|
||||||
|
|
||||||
return sourceBuffer - startPosition;
|
return sourceBuffer - startPosition;
|
||||||
|
|
|
@ -32,6 +32,7 @@ typedef unsigned long long quint64;
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
|
||||||
#include <QtCore/QJsonObject>
|
#include <QtCore/QJsonObject>
|
||||||
|
#include <QtCore/QReadWriteLock>
|
||||||
|
|
||||||
#include <NodeData.h>
|
#include <NodeData.h>
|
||||||
|
|
||||||
|
@ -69,8 +70,9 @@ public:
|
||||||
void setCameraCenterRadius(float radius) { _cameraCenterRadius = radius; }
|
void setCameraCenterRadius(float radius) { _cameraCenterRadius = radius; }
|
||||||
|
|
||||||
// getters/setters for JSON filter
|
// getters/setters for JSON filter
|
||||||
QJsonObject getJSONParameters() { return _jsonParameters; }
|
QJsonObject getJSONParameters() { QReadLocker locker { &_jsonParametersLock }; return _jsonParameters; }
|
||||||
void setJSONParameters(const QJsonObject& jsonParameters) { _jsonParameters = jsonParameters; }
|
void setJSONParameters(const QJsonObject& jsonParameters)
|
||||||
|
{ QWriteLocker locker { &_jsonParametersLock }; _jsonParameters = jsonParameters; }
|
||||||
|
|
||||||
// related to Octree Sending strategies
|
// related to Octree Sending strategies
|
||||||
int getMaxQueryPacketsPerSecond() const { return _maxQueryPPS; }
|
int getMaxQueryPacketsPerSecond() const { return _maxQueryPPS; }
|
||||||
|
@ -104,6 +106,7 @@ protected:
|
||||||
uint8_t _usesFrustum = true;
|
uint8_t _usesFrustum = true;
|
||||||
|
|
||||||
QJsonObject _jsonParameters;
|
QJsonObject _jsonParameters;
|
||||||
|
QReadWriteLock _jsonParametersLock;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// privatize the copy constructor and assignment operator so they cannot be called
|
// privatize the copy constructor and assignment operator so they cannot be called
|
||||||
|
|
Loading…
Reference in a new issue