Fixed avatar parent delete issue

This commit is contained in:
Dante Ruiz 2016-11-16 20:14:02 +00:00
parent 5ccfe3f6e8
commit ff7c11d48c
2 changed files with 15 additions and 0 deletions

View file

@ -438,6 +438,7 @@ void EntityTree::deleteEntity(const EntityItemID& entityID, bool force, bool ign
return; return;
} }
checkEntity(entityID);
emit deletingEntity(entityID); emit deletingEntity(entityID);
// NOTE: callers must lock the tree before using this method // NOTE: callers must lock the tree before using this method
@ -447,6 +448,17 @@ void EntityTree::deleteEntity(const EntityItemID& entityID, bool force, bool ign
_isDirty = true; _isDirty = true;
} }
void EntityTree::checkEntity(const EntityItemID entityID) {
EntityItemPointer entity = findEntityByEntityItemID(entityID);
entity->forEachChild([&](SpatiallyNestablePointer child) {
if (child->getNestableType() == NestableType::Avatar) {
child->setParentID(nullptr);
}
});
}
void EntityTree::deleteEntities(QSet<EntityItemID> entityIDs, bool force, bool ignoreWarnings) { void EntityTree::deleteEntities(QSet<EntityItemID> entityIDs, bool force, bool ignoreWarnings) {
// NOTE: callers must lock the tree before using this method // NOTE: callers must lock the tree before using this method
DeleteEntityOperator theOperator(getThisPointer()); DeleteEntityOperator theOperator(getThisPointer());
@ -476,6 +488,7 @@ void EntityTree::deleteEntities(QSet<EntityItemID> entityIDs, bool force, bool i
} }
// tell our delete operator about this entityID // tell our delete operator about this entityID
checkEntity(entityID);
theOperator.addEntityIDToDeleteList(entityID); theOperator.addEntityIDToDeleteList(entityID);
emit deletingEntity(entityID); emit deletingEntity(entityID);
} }

View file

@ -121,6 +121,8 @@ public:
// use this method if you have a pointer to the entity (avoid an extra entity lookup) // use this method if you have a pointer to the entity (avoid an extra entity lookup)
bool updateEntity(EntityItemPointer entity, const EntityItemProperties& properties, const SharedNodePointer& senderNode = SharedNodePointer(nullptr)); bool updateEntity(EntityItemPointer entity, const EntityItemProperties& properties, const SharedNodePointer& senderNode = SharedNodePointer(nullptr));
// check if the avatar is a child of this entity, If so set the avatar parentID to null
void checkEntity(const EntityItemID entityID);
void deleteEntity(const EntityItemID& entityID, bool force = false, bool ignoreWarnings = true); void deleteEntity(const EntityItemID& entityID, bool force = false, bool ignoreWarnings = true);
void deleteEntities(QSet<EntityItemID> entityIDs, bool force = false, bool ignoreWarnings = true); void deleteEntities(QSet<EntityItemID> entityIDs, bool force = false, bool ignoreWarnings = true);