Revision: 8676 http://playerstage.svn.sourceforge.net/playerstage/?rev=8676&view=rev Author: hsujohnhsu Date: 2010-05-13 06:38:16 +0000 (Thu, 13 May 2010)
Log Message: ----------- This check-in re-enables model deletion, but breaks body deletion. The calls to RemoveChild is commented out and a loop to delete bodies is added in Model's destructor. Still need to clean up RemoveChild in Entity and Model. Modified Paths: -------------- code/gazebo/trunk/server/Entity.cc code/gazebo/trunk/server/Model.cc Modified: code/gazebo/trunk/server/Entity.cc =================================================================== --- code/gazebo/trunk/server/Entity.cc 2010-05-12 03:07:21 UTC (rev 8675) +++ code/gazebo/trunk/server/Entity.cc 2010-05-13 06:38:16 UTC (rev 8676) @@ -81,8 +81,16 @@ // Destructor Entity::~Entity() { - if (this->parent) - this->parent->RemoveChild(this); + + // remove self as a child of the parent + //if (this->parent) + // this->parent->RemoveChild(this); + + // remove all connected joints for a Body before delteing it + // gazebo::Model* parent_model = dynamic_cast<gazebo::Model*>(this->parent); + // if (parent_model) + // parent_model->DeleteConnectedJoints(this); + this->SetParent(NULL); delete this->staticP; @@ -120,7 +128,6 @@ this->visualNode = NULL; } - //////////////////////////////////////////////////////////////////////////////// // Return the ID of the parent int Entity::GetParentId() const Modified: code/gazebo/trunk/server/Model.cc =================================================================== --- code/gazebo/trunk/server/Model.cc 2010-05-12 03:07:21 UTC (rev 8675) +++ code/gazebo/trunk/server/Model.cc 2010-05-13 06:38:16 UTC (rev 8676) @@ -99,8 +99,20 @@ // Destructor Model::~Model() { - //std::map< std::string, Body* >::iterator biter; - std::vector<Entity*>::iterator biter; + std::vector<Entity*>::iterator eiter; + for (eiter =this->children.begin(); eiter != this->children.end();) + if (*eiter && (*eiter)->GetType() == Entity::BODY) + { + //printf("~Model:deleting %s\n", (*eiter)->GetName().c_str()); + delete (*eiter); + *eiter = NULL; + this->children.erase(eiter); // effectively remove child + } + else + { + //printf("~Model:del not body %s\n", (*eiter)->GetName().c_str()); + eiter++; + } JointContainer::iterator jiter; std::map< std::string, Controller* >::iterator citer; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit