| 539 | } |
| 540 | |
| 541 | void Node::removeChild(Node* child, bool cleanup) { |
| 542 | AssertIf(child == nullptr, "remove invalid child (nullptr) from node."); |
| 543 | AssertIf(child->_parent != this, "can't remove child node from different parent."); |
| 544 | if (!_children) { |
| 545 | return; |
| 546 | } |
| 547 | auto childRef = Value::alloc(child); |
| 548 | if (_children->remove(childRef.get())) { |
| 549 | if (_flags.isOn(Node::Running)) { |
| 550 | child->onExit(); |
| 551 | } |
| 552 | if (cleanup) { |
| 553 | child->cleanup(); |
| 554 | } else { |
| 555 | child->_flags.setOn(Node::InWaitingList); |
| 556 | SharedDirector.addToWaitingList(child); |
| 557 | } |
| 558 | child->_parent = nullptr; |
| 559 | child->autorelease(); |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | void Node::removeChildByTag(String tag, bool cleanup) { |
| 564 | removeChild(getChildByTag(tag), cleanup); |
no test coverage detected