MCPcopy Create free account
hub / github.com/axmolengine/axmol / removeProtectedChild

Method removeProtectedChild

core/2d/ProtectedNode.cpp:148–188  ·  view source on GitHub ↗

"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 */

Source from the content-addressed store, hash-verified

146 * to override this method
147 */
148void 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
190void ProtectedNode::removeAllProtectedChildren()
191{

Callers 2

resetRenderMethod · 0.80

Calls 8

getInstanceFunction · 0.85
emptyMethod · 0.45
getIndexMethod · 0.45
onExitMethod · 0.45
cleanupMethod · 0.45
setParentMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected