File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -217,7 +217,15 @@ void Node::cleanup()
217
217
// timers
218
218
this ->unscheduleAllCallbacks ();
219
219
220
- _eventDispatcher->removeEventListenersForTarget (this );
220
+ // NOTE: Although it was correct that removing event listeners associated with current node in Node::cleanup.
221
+ // But it broke the compatibility to the versions before v3.16 .
222
+ // User code may call `node->removeFromParent(true)` which will trigger node's cleanup method, when the node
223
+ // is added to scene again, event listeners like EventListenerTouchOneByOne will be lost.
224
+ // In fact, user's code should use `node->removeFromParent(false)` in order not to do a cleanup and just remove node
225
+ // from its parent. For more discussion about why we revert this change is at https://github.com/cocos2d/cocos2d-x/issues/18104.
226
+ // We need to consider more before we want to correct the old and wrong logic code.
227
+ // For now, compatiblity is the most important for our users.
228
+ // _eventDispatcher->removeEventListenersForTarget(this);
221
229
222
230
for ( const auto &child: _children)
223
231
child->cleanup ();
You can’t perform that action at this time.
0 commit comments