Index: trunk/src/lib/coord/p_node.cc
===================================================================
--- trunk/src/lib/coord/p_node.cc	(revision 9656)
+++ trunk/src/lib/coord/p_node.cc	(revision 9869)
@@ -19,5 +19,4 @@
 
 #include "util/loading/load_param.h"
-#include "class_list.h"
 
 #include "netdefs.h"
@@ -30,4 +29,6 @@
 #include "color.h"
 
+
+ObjectListDefinition(PNode);
 /**
  * @brief standard constructor
@@ -38,5 +39,5 @@
   : BaseObject(), Synchronizeable()
 {
-  this->setClassID(CL_PARENT_NODE, "PNode");
+  this->registerObject(this, PNode::_objectList);
 
   this->bRelCoorChanged = true;
@@ -79,19 +80,25 @@
   PRINTF(4)("delete %s::%s\n", this->getClassCName(), this->getCName());
   // remove the Node, delete it's children (if required).
-  std::list<PNode*>::iterator deleteNode;
-  unsigned int size;
+  PNode* last = NULL;
+  //this->debugNode(0);
+
   while(!this->children.empty())
   {
-    deleteNode = this->children.begin();
-    size = this->children.size();
+    PNode* deleteNode = this->children.front();
+    if (deleteNode == last)
+    {
+      PRINTF(1)("Node same as last that was tried to be deleted. FORCE reparent to NULL of %p\n", deleteNode);
+      (deleteNode->setParent( NULL));
+      continue;
+    }
     if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) ||
-        ((*deleteNode)->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))
+        (deleteNode->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))
     {
-      if (this == PNode::nullParent && (*deleteNode)->parentMode & PNODE_REPARENT_TO_NULL)
+      if (this == PNode::nullParent && deleteNode->parentMode & PNODE_REPARENT_TO_NULL)
       {
         PRINTF(4)("%s::%s deletes %s::%s\n",
                   this->getClassCName(), this->getCName(),
-                  (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
-        delete (*deleteNode);
+                  deleteNode->getClassCName(), deleteNode->getCName());
+        delete deleteNode;
       }
       else
@@ -99,6 +106,6 @@
         PRINTF(4)("%s::%s reparents %s::%s\n",
                   this->getClassCName(), this->getCName(),
-                  (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
-        (*deleteNode)->reparent();
+                  deleteNode->getClassCName(), deleteNode->getCName());
+        deleteNode->reparent();
       }
     }
@@ -107,7 +114,8 @@
       PRINTF(4)("%s::%s deletes PNode: %s::%s\n",
                 this->getClassCName(), this->getCName(),
-                (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
-      delete (*deleteNode);
+                deleteNode->getClassCName(), deleteNode->getCName());
+      delete deleteNode;
     }
+    last = deleteNode;
   }
 
@@ -541,5 +549,5 @@
 void PNode::addChild (const std::string& childName)
 {
-  PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE));
+  PNode* childNode = PNode::objectList().getObject(childName);
   //  PRINTF(0)("Adding the Child: %s to: %s\n", childName, this->getName());
   //  assert( childNode != NULL );
@@ -625,5 +633,5 @@
 void PNode::setParent (const std::string& parentName)
 {
-  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
+  PNode* parentNode = PNode::objectList().getObject(parentName);
   if (parentNode != NULL)
     parentNode->addChild(this);
@@ -681,5 +689,5 @@
 void PNode::setParentSoft(const std::string& parentName, float bias)
 {
-  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
+  PNode* parentNode = PNode::objectList().getObject(parentName);
   if (parentNode != NULL)
     this->setParentSoft(parentNode, bias);
@@ -730,6 +738,6 @@
   if (likely(PNode::nullParent == NULL))
   {
-    PNode::nullParent = new PNode(NULL, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_TO_NULL);
-    PNode::nullParent->setClassID(CL_NULL_PARENT, "NullParent");
+    PNode::nullParent = new NullParent();
+    //PNode::nullParent->registerObject(, CL_NULL_PARENT);
     PNode::nullParent->setName("NullParent");
     PNode::nullParent->setSynchronized(true);
@@ -915,5 +923,5 @@
   int childNodeCount = 0;
   this->countChildNodes(childNodeCount);
-
+  printf("%p:", this);
   PRINT(0)("PNode(%s::%s) - absCoord: (%0.2f, %0.2f, %0.2f), relCoord(%0.2f, %0.2f, %0.2f), direction(%0.2f, %0.2f, %0.2f) - %s - %d childs\n",
            this->getClassCName(),
@@ -1106,3 +1114,9 @@
 }
 
-
+ObjectListDefinition(NullParent);
+
+NullParent::NullParent()
+  : PNode(NULL, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_TO_NULL)
+{
+  this->registerObject(this, NullParent::_objectList);
+}
