cocos2d-objc
cocos2d-objc copied to clipboard
Adding a node's parent as its child causes 37,400-deep recursion and EXC_BAD_ACCESS
This code:
CCNode *sprite1 = [CCNode node];
CCNode *sprite2 = [CCNode node];
[sprite2 addChild:sprite1];
[sprite1 addChild:sprite2];
produces an EXC_BAD_ACCESS error with a massive, 37,400-deep stack trace. It looks like the RecursivelyIncrementPausedAncestors recurses infinitely.
While it makes no sense to add a node's parent as its child, it should create some kind of meaningful error instead of crashing with EXC_BAD_ACCESS.
Bwa. I suppose we can have a debug mode assertion that checks if a node to be added is an ancestor of self.