Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5214 in orxonox.OLD for trunk/src/lib/coord


Ignore:
Timestamp:
Sep 21, 2005, 8:46:28 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: major fix in PNode/Element2D… the Children were removed twice when deleting an Instance

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/p_node.cc

    r5211 r5214  
    7878PNode::~PNode ()
    7979{
    80   tIterator<PNode>* iterator = this->children->getIterator();
    81   PNode* pn = iterator->firstElement();
    82   while( pn != NULL)
    83     {
    84       delete pn;
    85       pn = iterator->nextElement();
    86     }
    87   delete iterator;
    88   /* this deletes all children in the list */
    89   delete this->children;
    9080  if (this->parent)
    9181    this->parent->removeChild(this);
    92 
     82  else
     83  {
     84   tIterator<PNode>* iterator = this->children->getIterator();
     85   PNode* pn = iterator->firstElement();
     86   while( pn != NULL)
     87     {
     88       delete pn;
     89       pn = iterator->nextElement();
     90     }
     91   delete iterator;
     92   /* this deletes all children in the list */
     93  }
     94  delete this->children;
    9395  if (this->toCoordinate != NULL)
    9496    delete this->toCoordinate;
     
    422424void PNode::removeChild (PNode* child)
    423425{
    424   child->remove();
    425   this->children->remove(child);
    426   child->parent = NULL;
     426  if (child != NULL)
     427  {
     428   child->remove();
     429//   this->children->remove(child);
     430//   child->parent = NULL;
     431  }
    427432}
    428433
     
    434439void PNode::remove()
    435440{
    436   NullParent* nullParent = NullParent::getInstance();
    437 
    438441  tIterator<PNode>* iterator = this->children->getIterator();
    439442  PNode* pn = iterator->firstElement();
     
    441444  while( pn != NULL)
    442445    {
    443       nullParent->addChild(pn, pn->getParentMode());
     446      NullParent::getInstance()->addChild(pn, pn->getParentMode());
    444447      pn = iterator->nextElement();
    445448    }
    446449  delete iterator;
    447   this->parent->children->remove(this);
     450  if (this->parent != NULL)
     451    this->parent->children->remove(this);
    448452}
    449453
Note: See TracChangeset for help on using the changeset viewer.