"remove" logic MUST only be on this method * If a class want's to extend the 'removeChild' behavior it only needs * to override this method */
| 146 | * to override this method |
| 147 | */ |
| 148 | void ProtectedNode::removeProtectedChild(ax::Node* child, bool cleanup) |
| 149 | { |
| 150 | // explicit nil handling |
| 151 | if (_protectedChildren.empty()) |
| 152 | { |
| 153 | return; |
| 154 | } |
| 155 | |
| 156 | ssize_t index = _protectedChildren.getIndex(child); |
| 157 | if (index != AX_INVALID_INDEX) |
| 158 | { |
| 159 | |
| 160 | // IMPORTANT: |
| 161 | // -1st do onExit |
| 162 | // -2nd cleanup |
| 163 | if (_running) |
| 164 | { |
| 165 | child->onExitTransitionDidStart(); |
| 166 | child->onExit(); |
| 167 | } |
| 168 | |
| 169 | // If you don't do cleanup, the child's actions will not get removed and the |
| 170 | // its scheduledSelectors_ dict will not get released! |
| 171 | if (cleanup) |
| 172 | { |
| 173 | child->cleanup(); |
| 174 | } |
| 175 | |
| 176 | // set parent nil at the end |
| 177 | child->setParent(nullptr); |
| 178 | |
| 179 | #if AX_ENABLE_GC_FOR_NATIVE_OBJECTS |
| 180 | auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine(); |
| 181 | if (sEngine) |
| 182 | { |
| 183 | sEngine->releaseScriptObject(this, child); |
| 184 | } |
| 185 | #endif // AX_ENABLE_GC_FOR_NATIVE_OBJECTS |
| 186 | _protectedChildren.erase(index); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | void ProtectedNode::removeAllProtectedChildren() |
| 191 | { |
no test coverage detected