Changeset 7910
- Timestamp:
- Feb 18, 2011, 12:07:04 AM (14 years ago)
- Location:
- code/trunk/src/orxonox/worldentities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/worldentities/WorldEntity.cc
r7905 r7910 120 120 this->detachFromParent(); 121 121 122 for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ) 123 { 122 std::set<WorldEntity*>::iterator it; 123 while ((it = this->children_.begin()) != this->children_.end()) 124 { 125 // do this for all children, because even if getDeleteWithParent() returns true a child might still stay active due to smart pointers pointing to it 126 (*it)->setPosition((*it)->getWorldPosition()); 127 this->detach(*it); // detach also erases the element from the children set 128 124 129 if ((*it)->getDeleteWithParent()) 125 (*(it++))->destroy(); 126 else 127 { 128 (*it)->setPosition((*it)->getWorldPosition()); 129 this->detach(*(it++)); 130 } 130 (*it)->destroy(); 131 131 } 132 132 … … 450 450 void WorldEntity::detach(WorldEntity* object) 451 451 { 452 if (this->children_.find(object) == this->children_.end()) 452 std::set<WorldEntity*>::iterator it = this->children_.find(object); 453 if (it == this->children_.end()) 453 454 { 454 455 CCOUT(2) << "Warning: Cannot detach an object that is not a child." << std::endl; … … 467 468 468 469 this->detachNode(object->node_); 469 this->children_.erase( object);470 this->children_.erase(it); 470 471 471 472 object->notifyDetached(); -
code/trunk/src/orxonox/worldentities/WorldEntity.h
r7401 r7910 214 214 private: 215 215 void registerVariables(); 216 216 217 217 inline void lookAt_xmlport(const Vector3& target) 218 218 { this->lookAt(target); }
Note: See TracChangeset
for help on using the changeset viewer.