FIX: check if child is not nullptr on adding

This commit is contained in:
Dominik Meyer 2019-04-07 16:32:56 +02:00
parent 22739d8ac4
commit 2850647c66
No known key found for this signature in database
GPG Key ID: B4C312B600606B64
1 changed files with 7 additions and 1 deletions

View File

@ -168,7 +168,13 @@ namespace Tree
*
* @param c - a shared_ptr to a BaseNode
*/
void addChild(const std::shared_ptr<Tree::BaseNode> &c) {c->setParent(shared_from_this()); children.push_back(c); }
void addChild(const std::shared_ptr<Tree::BaseNode> &c) {
if (c!=nullptr)
{
c->setParent(shared_from_this());
children.push_back(c);
}
}
/**