]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
get the parentparent reference before changing the nodes; this should fix a segfault...
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Fri, 27 Mar 2009 09:21:52 +0000 (09:21 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Fri, 27 Mar 2009 09:21:52 +0000 (09:21 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@232 61c419a2-8eb2-4b30-bcec-8cead039b335

radiant/entity.cpp

index c9d00e401a43e779ff83560c0f729ccc436283b9..4fa32ee7157e53b8c9d92829535c758aed518e92 100644 (file)
@@ -184,37 +184,49 @@ public:
 
 class EntityGroupSelected : public scene::Graph::Walker
 {
-  NodeSmartReference group;
-public:
-  EntityGroupSelected(const scene::Path &p): group(p.top().get())
-  {
-  }
-  bool pre(const scene::Path& path, scene::Instance& instance) const
-  {
-    return true;
-  }
-  void post(const scene::Path& path, scene::Instance& instance) const
-  {
-       Selectable *selectable = Instance_getSelectable(instance);
-    if(selectable && selectable->isSelected())
-    { 
-         Entity* entity = Node_getEntity(path.top());
-         if(entity == 0 && Node_isPrimitive(path.top()))
-         {
-                 NodeSmartReference child(path.top().get());
-                 NodeSmartReference parent(path.parent().get());
-
-                 Node_getTraversable(parent)->erase(child);
-                 Node_getTraversable(group)->insert(child);
-
-                 if(Node_getTraversable(parent)->empty() && path.size() >= 3 && parent != Map_FindOrInsertWorldspawn(g_map))
-                 {
-                         NodeSmartReference parentparent(path[path.size() - 3].get());
-                         Node_getTraversable(parentparent)->erase(parent);
-                 }
-         }
-    }
-  }
+       NodeSmartReference group;
+       //typedef std::pair<NodeSmartReference, NodeSmartReference> DeletionPair;
+       //Stack<DeletionPair> deleteme;
+       public:
+       EntityGroupSelected(const scene::Path &p): group(p.top().get())
+       {
+       }
+       bool pre(const scene::Path& path, scene::Instance& instance) const
+       {
+               return true;
+       }
+       void post(const scene::Path& path, scene::Instance& instance) const
+       {
+               Selectable *selectable = Instance_getSelectable(instance);
+               if(selectable && selectable->isSelected())
+               { 
+                       Entity* entity = Node_getEntity(path.top());
+                       if(entity == 0 && Node_isPrimitive(path.top()))
+                       {
+                               NodeSmartReference child(path.top().get());
+                               NodeSmartReference parent(path.parent().get());
+
+                               if(path.size() >= 3 && parent != Map_FindOrInsertWorldspawn(g_map))
+                               {
+                                       NodeSmartReference parentparent(path[path.size() - 3].get());
+
+                                       Node_getTraversable(parent)->erase(child);
+                                       Node_getTraversable(group)->insert(child);
+
+                                       if(Node_getTraversable(parent)->empty())
+                                       {
+                                               //deleteme.push(DeletionPair(parentparent, parent));
+                                               Node_getTraversable(parentparent)->erase(parent);
+                                       }
+                               }
+                               else
+                               {
+                                       Node_getTraversable(parent)->erase(child);
+                                       Node_getTraversable(group)->insert(child);
+                               }
+                       }
+               }
+       }
 };
 
 void Entity_groupSelected()