apparently calling FindOrInsertWorldspawn during tree traversing is bad, so let's...
authorRudolf Polzer <divverent@alientrap.org>
Mon, 1 Nov 2010 06:43:42 +0000 (07:43 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Mon, 1 Nov 2010 06:43:42 +0000 (07:43 +0100)
radiant/entity.cpp
radiant/mainframe.cpp
radiant/select.cpp

index 055de63..9478bda 100644 (file)
@@ -184,11 +184,11 @@ public:
 
 class EntityGroupSelected : public scene::Graph::Walker
 {
-       NodeSmartReference group;
+       NodeSmartReference group, worldspawn;
        //typedef std::pair<NodeSmartReference, NodeSmartReference> DeletionPair;
        //Stack<DeletionPair> deleteme;
        public:
-       EntityGroupSelected(const scene::Path &p): group(p.top().get())
+       EntityGroupSelected(const scene::Path &p): group(p.top().get()), worldspawn(Map_FindOrInsertWorldspawn(g_map))
        {
        }
        bool pre(const scene::Path& path, scene::Instance& instance) const
@@ -206,7 +206,7 @@ class EntityGroupSelected : public scene::Graph::Walker
                                NodeSmartReference child(path.top().get());
                                NodeSmartReference parent(path.parent().get());
 
-                               if(path.size() >= 3 && parent != Map_FindOrInsertWorldspawn(g_map))
+                               if(path.size() >= 3 && parent != worldspawn)
                                {
                                        NodeSmartReference parentparent(path[path.size() - 3].get());
 
index 7f7eb06..ea4edf3 100644 (file)
@@ -1189,8 +1189,11 @@ void SelectFaceMode()
 class CloneSelected : public scene::Graph::Walker
 {
   bool doMakeUnique;
+  NodeSmartReference worldspawn;
 public:
-  CloneSelected(bool d): doMakeUnique(d) { }
+  CloneSelected(bool d): doMakeUnique(d), worldspawn(Map_FindOrInsertWorldspawn(g_map))
+  {
+  }
   bool pre(const scene::Path& path, scene::Instance& instance) const
   {
     if(path.size() == 1)
@@ -1198,7 +1201,7 @@ public:
 
     // ignore worldspawn, but keep checking children
     NodeSmartReference me(path.top().get());
-    if(me == Map_FindOrInsertWorldspawn(g_map))
+    if(me == worldspawn)
            return true;
 
     if(!path.top().get().isRoot())
@@ -1220,7 +1223,7 @@ public:
 
     // ignore worldspawn, but keep checking children
     NodeSmartReference me(path.top().get());
-    if(me == Map_FindOrInsertWorldspawn(g_map))
+    if(me == worldspawn)
            return;
 
     if(!path.top().get().isRoot())
index 79721e9..5889fd5 100644 (file)
@@ -340,8 +340,9 @@ void Select_Invert()
 class ExpandSelectionToEntitiesWalker : public scene::Graph::Walker
 {
   mutable std::size_t m_depth;
+  NodeSmartReference worldspawn;
 public:
-  ExpandSelectionToEntitiesWalker() : m_depth(0)
+  ExpandSelectionToEntitiesWalker() : m_depth(0), worldspawn(Map_FindOrInsertWorldspawn(g_map))
   {
   }
   bool pre(const scene::Path& path, scene::Instance& instance) const
@@ -350,7 +351,7 @@ public:
 
     // ignore worldspawn
     NodeSmartReference me(path.top().get());
-    if(me == Map_FindOrInsertWorldspawn(g_map))
+    if(me == worldspawn)
            return false;
 
     if(m_depth == 2) // entity depth