From e96c3e84b42842d8ca4b305a2ed68d8e0b409514 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 3 May 2017 13:58:49 -0700 Subject: [PATCH 01/14] if a script attempts to edit a non-entity, don't send the edit packet over the wire --- libraries/entities/src/EntityScriptingInterface.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 10479e931c..7b2f8b8554 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -407,9 +407,11 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& // return QUuid(); // } + bool entityFound = false; _entityTree->withReadLock([&] { EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); if (entity) { + entityFound = true; // make sure the properties has a type, so that the encode can know which properties to include properties.setType(entity->getType()); bool hasTerseUpdateChanges = properties.hasTerseUpdateChanges(); @@ -464,7 +466,11 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& }); } }); - queueEntityMessage(PacketType::EntityEdit, entityID, properties); + if (entityFound) { + queueEntityMessage(PacketType::EntityEdit, entityID, properties); + } else { + qDebug() << "warning: attempted edit on unknown entity: " << id; + } return id; } From 0fff7678bf4836feee84e33fa791e13daf0788ac Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 3 May 2017 19:07:46 -0700 Subject: [PATCH 02/14] code review --- libraries/entities/src/EntityScriptingInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 7b2f8b8554..2189970cc7 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -407,7 +407,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& // return QUuid(); // } - bool entityFound = false; + bool entityFound { false }; _entityTree->withReadLock([&] { EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); if (entity) { @@ -469,7 +469,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& if (entityFound) { queueEntityMessage(PacketType::EntityEdit, entityID, properties); } else { - qDebug() << "warning: attempted edit on unknown entity: " << id; + qCWarning(entities) << "attempted edit on unknown entity: " << id; } return id; } From ed09dcbdc948d102918efc09a233e50051a6adc3 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 3 May 2017 21:32:06 -0700 Subject: [PATCH 03/14] don't call editEntity on overlays --- scripts/system/libraries/WebTablet.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index e71aefc51e..5355677bf7 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -274,7 +274,8 @@ WebTablet.prototype.getLocation = function() { }; WebTablet.prototype.setHomeButtonTexture = function() { - Entities.editEntity(this.tabletEntityID, {textures: JSON.stringify({"tex.close": HOME_BUTTON_TEXTURE})}); + // TODO - is this still needed? + // Entities.editEntity(this.tabletEntityID, {textures: JSON.stringify({"tex.close": HOME_BUTTON_TEXTURE})}); }; WebTablet.prototype.setURL = function (url) { @@ -337,7 +338,8 @@ WebTablet.prototype.geometryChanged = function (geometry) { // compute position, rotation & parentJointIndex of the tablet this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); - Entities.editEntity(this.tabletEntityID, tabletProperties); + // TODO -- is this still needed? + // Entities.editEntity(this.tabletEntityID, tabletProperties); } }; @@ -438,7 +440,8 @@ WebTablet.prototype.onHmdChanged = function () { var tabletProperties = {}; // compute position, rotation & parentJointIndex of the tablet this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); - Entities.editEntity(this.tabletEntityID, tabletProperties); + // TODO -- is this still needed? + // Entities.editEntity(this.tabletEntityID, tabletProperties); // Full scene FXAA should be disabled on the overlay when the tablet in desktop mode. // This should make the text more readable. @@ -529,7 +532,8 @@ WebTablet.prototype.cameraModeChanged = function (newMode) { var tabletProperties = {}; // compute position, rotation & parentJointIndex of the tablet self.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); - Entities.editEntity(self.tabletEntityID, tabletProperties); + // TODO -- is this still needed? + // Entities.editEntity(self.tabletEntityID, tabletProperties); } }; From 69944cc76dcfa1485e6c8a613b188729023766f9 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 3 May 2017 21:32:49 -0700 Subject: [PATCH 04/14] add a way to get a SpatiallyNestable's name without knowing what its type is --- interface/src/ui/overlays/Base3DOverlay.cpp | 7 +++++++ interface/src/ui/overlays/Base3DOverlay.h | 5 +++++ libraries/avatars/src/AvatarData.h | 2 ++ libraries/entities/src/EntityItem.h | 2 +- .../entities/src/EntityScriptingInterface.cpp | 14 +++++++++++++- libraries/shared/src/SpatiallyNestable.h | 2 ++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/overlays/Base3DOverlay.cpp b/interface/src/ui/overlays/Base3DOverlay.cpp index d7057c6faa..6f1167cfc9 100644 --- a/interface/src/ui/overlays/Base3DOverlay.cpp +++ b/interface/src/ui/overlays/Base3DOverlay.cpp @@ -81,6 +81,10 @@ QVariantMap convertOverlayLocationFromScriptSemantics(const QVariantMap& propert void Base3DOverlay::setProperties(const QVariantMap& originalProperties) { QVariantMap properties = originalProperties; + if (properties["name"].isValid()) { + setName(properties["name"].toString()); + } + // carry over some legacy keys if (!properties["position"].isValid() && !properties["localPosition"].isValid()) { if (properties["p1"].isValid()) { @@ -207,6 +211,9 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) { } QVariant Base3DOverlay::getProperty(const QString& property) { + if (property == "name") { + return _name; + } if (property == "position" || property == "start" || property == "p1" || property == "point") { return vec3toVariant(getPosition()); } diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h index a1c23e5cd8..29d4c093a9 100644 --- a/interface/src/ui/overlays/Base3DOverlay.h +++ b/interface/src/ui/overlays/Base3DOverlay.h @@ -26,6 +26,9 @@ public: virtual OverlayID getOverlayID() const override { return OverlayID(getID().toString()); } void setOverlayID(OverlayID overlayID) override { setID(overlayID); } + virtual QString getName() const override { return QString("Overlay:") + _name; } + void setName(QString name) { _name = name; } + // getters virtual bool is3D() const override { return true; } @@ -74,6 +77,8 @@ protected: bool _drawInFront; bool _isAA; bool _isGrabbable { false }; + + QString _name; }; #endif // hifi_Base3DOverlay_h diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index b4c79470de..a93f37839f 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -357,6 +357,8 @@ class AvatarData : public QObject, public SpatiallyNestable { public: + virtual QString getName() const override { return QString("Avatar:") + _displayName; } + static const QString FRAME_NAME; static void fromFrame(const QByteArray& frameData, AvatarData& avatar, bool useFrameSkeleton = true); diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index ff5f12b2f7..1896893b52 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -281,7 +281,7 @@ public: float getAngularDamping() const; void setAngularDamping(float value); - QString getName() const; + virtual QString getName() const override; void setName(const QString& value); QString getDebugName(); diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 2189970cc7..c499ce4acc 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -469,7 +469,19 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& if (entityFound) { queueEntityMessage(PacketType::EntityEdit, entityID, properties); } else { - qCWarning(entities) << "attempted edit on unknown entity: " << id; + QString name = "unknown"; + QSharedPointer parentFinder = DependencyManager::get(); + if (parentFinder) { + bool success; + auto nestableWP = parentFinder->find(id, success, static_cast(_entityTree.get())); + if (success) { + auto nestable = nestableWP.lock(); + if (nestable) { + name = nestable->getName(); + } + } + } + qCWarning(entities) << "attempted edit on unknown entity: " << id << name; } return id; } diff --git a/libraries/shared/src/SpatiallyNestable.h b/libraries/shared/src/SpatiallyNestable.h index 820c8685d7..0f89016f54 100644 --- a/libraries/shared/src/SpatiallyNestable.h +++ b/libraries/shared/src/SpatiallyNestable.h @@ -42,6 +42,8 @@ public: virtual const QUuid getID() const; virtual void setID(const QUuid& id); + virtual QString getName() const { return "SpatiallyNestable"; } + virtual const QUuid getParentID() const; virtual void setParentID(const QUuid& parentID); From 9171995ed32f0fbbdf1ee05a32283e533cf40610 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 3 May 2017 21:41:00 -0700 Subject: [PATCH 05/14] add a comment --- libraries/entities/src/EntityScriptingInterface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index c499ce4acc..153d9044e9 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -469,6 +469,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& if (entityFound) { queueEntityMessage(PacketType::EntityEdit, entityID, properties); } else { + // attempt to get a name for the mystery ID QString name = "unknown"; QSharedPointer parentFinder = DependencyManager::get(); if (parentFinder) { From 74a82f92df94b21909532cd8b563177dc6a96409 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 May 2017 10:05:17 -0700 Subject: [PATCH 06/14] return null uuid for failure --- libraries/entities/src/EntityScriptingInterface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 153d9044e9..a4ec7b7636 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -483,6 +483,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& } } qCWarning(entities) << "attempted edit on unknown entity: " << id << name; + return QUuid(); // null UUID to indicate failure } return id; } From c04c0c5b13090056ea332f10d11d766578d7c678 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 May 2017 18:36:51 -0700 Subject: [PATCH 07/14] if model-overlay has no name, use its url --- interface/src/ui/overlays/ModelOverlay.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index e993166558..8360dc186b 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -279,3 +279,10 @@ void ModelOverlay::locationChanged(bool tellPhysics) { _model->setTranslation(getPosition()); } } + +QString ModelOverlay::getName() const { + if (_name != "") { + return QString("Overlay:") + getType() + ":" + _name; + } + return QString("Overlay:") + getType() + ":" + _url.toString(); +} From 0406cc41e0da1136c0cd384205812c6fad5becf6 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 May 2017 18:37:04 -0700 Subject: [PATCH 08/14] if model-overlay has no name, use its url --- interface/src/ui/overlays/ModelOverlay.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/src/ui/overlays/ModelOverlay.h b/interface/src/ui/overlays/ModelOverlay.h index 8afe9a20b6..312f88dcb5 100644 --- a/interface/src/ui/overlays/ModelOverlay.h +++ b/interface/src/ui/overlays/ModelOverlay.h @@ -22,6 +22,8 @@ public: static QString const TYPE; virtual QString getType() const override { return TYPE; } + virtual QString getName() const override; + ModelOverlay(); ModelOverlay(const ModelOverlay* modelOverlay); From d25db099b94619596d975e9024aa5484cd1bbdb7 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 May 2017 18:49:46 -0700 Subject: [PATCH 09/14] be more effecient about ignoring edits to unknown entities --- libraries/entities/src/EntityTree.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 3ad5cc92a5..76483d0786 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -990,6 +990,17 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c entityItemID, properties); endDecode = usecTimestampNow(); + EntityItemPointer existingEntity; + if (!isAdd) { + // search for the entity by EntityItemID + startLookup = usecTimestampNow(); + existingEntity = findEntityByEntityItemID(entityItemID); + endLookup = usecTimestampNow(); + if (!existingEntity) { + // this is not an add-entity operation, and we don't know about the identified entity. + validEditPacket = false; + } + } if (validEditPacket && !_entityScriptSourceWhitelist.isEmpty() && !properties.getScript().isEmpty()) { bool passedWhiteList = false; @@ -1036,12 +1047,6 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c // If we got a valid edit packet, then it could be a new entity or it could be an update to // an existing entity... handle appropriately if (validEditPacket) { - - // search for the entity by EntityItemID - startLookup = usecTimestampNow(); - EntityItemPointer existingEntity = findEntityByEntityItemID(entityItemID); - endLookup = usecTimestampNow(); - startFilter = usecTimestampNow(); bool wasChanged = false; // Having (un)lock rights bypasses the filter, unless it's a physics result. From 70efe4aa4f0242cf957dde3ec54e540be045d12f Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 May 2017 18:52:17 -0700 Subject: [PATCH 10/14] avoid calling editEntity on overlays --- scripts/system/controllers/handControllerGrab.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index db0840b078..b05f0b241b 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -3878,6 +3878,7 @@ function MyController(hand) { // we appear to be holding something and this script isn't in a state that would be holding something. // unhook it. if we previously took note of this entity's parent, put it back where it was. This // works around some problems that happen when more than one hand or avatar is passing something around. + var childType = Entities.getNestableType(childID); if (_this.previousParentID[childID]) { var previousParentID = _this.previousParentID[childID]; var previousParentJointIndex = _this.previousParentJointIndex[childID]; @@ -3895,7 +3896,7 @@ function MyController(hand) { } _this.previouslyUnhooked[childID] = now; - if (Overlays.getProperty(childID, "grabbable")) { + if (childType == "overlay" && Overlays.getProperty(childID, "grabbable")) { // only auto-unhook overlays that were flagged as grabbable. this avoids unhooking overlays // used in tutorial. Overlays.editOverlay(childID, { @@ -3903,7 +3904,12 @@ function MyController(hand) { parentJointIndex: previousParentJointIndex }); } - Entities.editEntity(childID, { parentID: previousParentID, parentJointIndex: previousParentJointIndex }); + if (childType == "entity") { + Entities.editEntity(childID, { + parentID: previousParentID, + parentJointIndex: previousParentJointIndex + }); + } } else { Entities.editEntity(childID, { parentID: NULL_UUID }); From 51cb5797739c7acd46700915865ed424eda80a3f Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 May 2017 19:05:01 -0700 Subject: [PATCH 11/14] function to turn nestable-type into a string --- libraries/shared/src/SpatiallyNestable.cpp | 14 ++++++++++++++ libraries/shared/src/SpatiallyNestable.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/libraries/shared/src/SpatiallyNestable.cpp b/libraries/shared/src/SpatiallyNestable.cpp index 75574967e4..9c7e216cb6 100644 --- a/libraries/shared/src/SpatiallyNestable.cpp +++ b/libraries/shared/src/SpatiallyNestable.cpp @@ -1138,3 +1138,17 @@ SpatiallyNestablePointer SpatiallyNestable::findByID(QUuid id, bool& success) { } return parentWP.lock(); } + + +QString SpatiallyNestable::nestableTypeToString(NestableType nestableType) { + switch(nestableType) { + case NestableType::Entity: + return "entity"; + case NestableType::Avatar: + return "avatar"; + case NestableType::Overlay: + return "overlay"; + default: + return "unknown"; + } +} diff --git a/libraries/shared/src/SpatiallyNestable.h b/libraries/shared/src/SpatiallyNestable.h index 0f89016f54..e8961dba98 100644 --- a/libraries/shared/src/SpatiallyNestable.h +++ b/libraries/shared/src/SpatiallyNestable.h @@ -64,6 +64,8 @@ public: static glm::vec3 localToWorldAngularVelocity(const glm::vec3& angularVelocity, const QUuid& parentID, int parentJointIndex, bool& success); + static QString nestableTypeToString(NestableType nestableType); + // world frame virtual const Transform getTransform(bool& success, int depth = 0) const; virtual const Transform getTransform() const; From a7c684e007692fabbb4e684a08d2441999b0220a Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 May 2017 19:05:29 -0700 Subject: [PATCH 12/14] entity scripting call to get the nestable-type of an object, by id --- .../entities/src/EntityScriptingInterface.cpp | 33 +++++++++++++++---- .../entities/src/EntityScriptingInterface.h | 2 ++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index a4ec7b7636..83bc2184a8 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -466,9 +466,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& }); } }); - if (entityFound) { - queueEntityMessage(PacketType::EntityEdit, entityID, properties); - } else { + if (!entityFound) { // attempt to get a name for the mystery ID QString name = "unknown"; QSharedPointer parentFinder = DependencyManager::get(); @@ -478,13 +476,18 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& if (success) { auto nestable = nestableWP.lock(); if (nestable) { - name = nestable->getName(); + NestableType nestableType = nestable->getNestableType(); + if (nestableType == NestableType::Overlay || nestableType == NestableType::Avatar) { + qCWarning(entities) << "attempted edit on non-entity: " << id << name; + return QUuid(); // null UUID to indicate failure + } } } } - qCWarning(entities) << "attempted edit on unknown entity: " << id << name; - return QUuid(); // null UUID to indicate failure } + // we queue edit packets even if we don't know about the entity. This is to allow AC agents + // to edit entities they know only by ID. + queueEntityMessage(PacketType::EntityEdit, entityID, properties); return id; } @@ -1535,6 +1538,24 @@ bool EntityScriptingInterface::isChildOfParent(QUuid childID, QUuid parentID) { return isChild; } +QString EntityScriptingInterface::getNestableType(QUuid id) { + QSharedPointer parentFinder = DependencyManager::get(); + if (!parentFinder) { + return "unknown"; + } + bool success; + SpatiallyNestableWeakPointer objectWP = parentFinder->find(id, success); + if (!success) { + return "unknown"; + } + SpatiallyNestablePointer object = objectWP.lock(); + if (!object) { + return "unknown"; + } + NestableType nestableType = object->getNestableType(); + return SpatiallyNestable::nestableTypeToString(nestableType); +} + QVector EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex) { QVector result; if (!_entityTree) { diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index b25764790e..f5656860e3 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -304,6 +304,8 @@ public slots: Q_INVOKABLE QVector getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex); Q_INVOKABLE bool isChildOfParent(QUuid childID, QUuid parentID); + Q_INVOKABLE QString getNestableType(QUuid id); + Q_INVOKABLE QUuid getKeyboardFocusEntity() const; Q_INVOKABLE void setKeyboardFocusEntity(QUuid id); From 900fae30fdff36fb384ad574fb7bd47ad4368e67 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 May 2017 19:05:52 -0700 Subject: [PATCH 13/14] avoid calling editEntity on overlays --- scripts/system/controllers/handControllerGrab.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index b05f0b241b..adec4d7258 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -3912,9 +3912,12 @@ function MyController(hand) { } } else { - Entities.editEntity(childID, { parentID: NULL_UUID }); - if (Overlays.getProperty(childID, "grabbable")) { - Overlays.editOverlay(childID, { parentID: NULL_UUID }); + if (childType == "entity") { + Entities.editEntity(childID, { parentID: NULL_UUID }); + } else if (childType == "overlay") { + if (Overlays.getProperty(childID, "grabbable")) { + Overlays.editOverlay(childID, { parentID: NULL_UUID }); + } } } } From 7f4399b0a38369b06093aea08b3d1494f80fe8c1 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 May 2017 19:16:15 -0700 Subject: [PATCH 14/14] fix name in entity-edit-an-overlay warning --- libraries/entities/src/EntityScriptingInterface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 83bc2184a8..ffb65a2dba 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -467,8 +467,8 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& } }); if (!entityFound) { - // attempt to get a name for the mystery ID - QString name = "unknown"; + // we've made an edit to an entity we don't know about, or to a non-entity. If it's a known non-entity, + // print a warning and don't send an edit packet to the entity-server. QSharedPointer parentFinder = DependencyManager::get(); if (parentFinder) { bool success; @@ -478,7 +478,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& if (nestable) { NestableType nestableType = nestable->getNestableType(); if (nestableType == NestableType::Overlay || nestableType == NestableType::Avatar) { - qCWarning(entities) << "attempted edit on non-entity: " << id << name; + qCWarning(entities) << "attempted edit on non-entity: " << id << nestable->getName(); return QUuid(); // null UUID to indicate failure } }