get the parentparent reference before changing the nodes; this should fix a segfault in regrouping

git-svn-id: svn://svn.icculus.org/netradiant/trunk@232 61c419a2-8eb2-4b30-bcec-8cead039b335
This commit is contained in:
divverent 2009-03-27 09:21:52 +00:00
parent 03d8a175d4
commit 08732dbb75

View File

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