mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
Update EntityTree.cpp to not delete entity when locked
This commit is contained in:
parent
86f7c28ee9
commit
f65640a593
1 changed files with 39 additions and 3 deletions
|
@ -229,6 +229,23 @@ void EntityTree::setSimulation(EntitySimulation* simulation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::deleteEntity(const EntityItemID& entityID) {
|
void EntityTree::deleteEntity(const EntityItemID& entityID) {
|
||||||
|
EntityTreeElement* containingElement = getContainingElement(entityID);
|
||||||
|
if (!containingElement) {
|
||||||
|
qDebug() << "UNEXPECTED!!!! EntityTree::deleteEntity() entityID doesn't exist!!! entityID=" << entityID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityItem* existingEntity = containingElement->getEntityWithEntityItemID(entityID);
|
||||||
|
if (!existingEntity) {
|
||||||
|
qDebug() << "UNEXPECTED!!!! don't call EntityTree::deleteEntity() on entity items that don't exist. entityID=" << entityID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingEntity->getLocked()) {
|
||||||
|
qDebug() << "ERROR! EntityTree::deleteEntity() trying to delete locked entity. entityID=" << entityID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
|
@ -242,14 +259,33 @@ void EntityTree::deleteEntities(QSet<EntityItemID> entityIDs) {
|
||||||
// NOTE: callers must lock the tree before using this method
|
// NOTE: callers must lock the tree before using this method
|
||||||
DeleteEntityOperator theOperator(this);
|
DeleteEntityOperator theOperator(this);
|
||||||
foreach(const EntityItemID& entityID, entityIDs) {
|
foreach(const EntityItemID& entityID, entityIDs) {
|
||||||
|
EntityTreeElement* containingElement = getContainingElement(entityID);
|
||||||
|
if (!containingElement) {
|
||||||
|
qDebug() << "UNEXPECTED!!!! EntityTree::deleteEntities() entityID doesn't exist!!! entityID=" << entityID;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityItem* existingEntity = containingElement->getEntityWithEntityItemID(entityID);
|
||||||
|
if (!existingEntity) {
|
||||||
|
qDebug() << "UNEXPECTED!!!! don't call EntityTree::deleteEntities() on entity items that don't exist. entityID=" << entityID;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingEntity->getLocked()) {
|
||||||
|
qDebug() << "ERROR! EntityTree::deleteEntities() trying to delete locked entity. entityID=" << entityID;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// tell our delete operator about this entityID
|
// tell our delete operator about this entityID
|
||||||
theOperator.addEntityIDToDeleteList(entityID);
|
theOperator.addEntityIDToDeleteList(entityID);
|
||||||
emit deletingEntity(entityID);
|
emit deletingEntity(entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
recurseTreeWithOperator(&theOperator);
|
if (theOperator.getEntities().size() > 0) {
|
||||||
processRemovedEntities(theOperator);
|
recurseTreeWithOperator(&theOperator);
|
||||||
_isDirty = true;
|
processRemovedEntities(theOperator);
|
||||||
|
_isDirty = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::processRemovedEntities(const DeleteEntityOperator& theOperator) {
|
void EntityTree::processRemovedEntities(const DeleteEntityOperator& theOperator) {
|
||||||
|
|
Loading…
Reference in a new issue