fix for erasure handling of nodes and components

This commit is contained in:
Hartmut Seichter 2019-01-07 16:28:22 +01:00
parent 74aae08122
commit 28bdf476ca
2 changed files with 24 additions and 9 deletions

View file

@ -51,11 +51,17 @@ node::ref node::add_child()
void node::remove_child(ref child_node)
{
node::ref_array::iterator it = _children.end();
for (node::ref_array::iterator it = _children.begin();
it != _children.end();
it++)
{
if (child_node == *it) it = _children.erase(it);
}
// auto it = _children.end();
while ((it = std::find(_children.begin(),_children.end(),child_node)) != _children.end()) {
_children.erase(it);
}
// while (it = std::find(_children.begin(),_children.end(),child_node) != _children.end()) {
// it = _children.erase(it);
// }
}
node::~node()
@ -74,12 +80,20 @@ void node::add_component(component::ref new_component)
void node::remove_component(component::ref c)
{
component::array::iterator it = _components.end();
// component::array::iterator it = _components.end();
while ((it = std::find(_components.begin(),_components.end(),c)) != _components.end()) {
(*it)->_node = nullptr;
_components.erase(it);
}
for (component::array::iterator it = _components.begin();
it != _components.end();
it++)
{
if (*it == c) it = _components.erase(it);
}
// while ((it = std::find(_components.begin(),_components.end(),c)) != _components.end()) {
// (*it)->_node = nullptr;
// _components.erase(it);
// }
}
const node::ptr_array &node::path() const