I have following issue. I have (in general) two nodes: 1 and 2. Every node has running actions. When node 1 actions are finished I remove node 2 (node 2 actions are still running). Node 2 is removed, but destructor is not called (refCount > 0). However, when node 2 actions are finished and after that node 1 calls to remove node 2, destructor of the node 2 is called.
Any idea? I tried stopAllActions, removeAllActionsFromTarget before removing node 2, but without success.
When runAction is called ref count of the node is incremented. When node 2 with running actions is removed, those actions are not stopped/removed. It looks like actions are in some “suspended” mode. They are not finishing so ref count can’t be decremented and node is not removed from the memory. Am I right? Is there any solution for that?
Thanks. removeChild(node) does the same and the result is also the same. The workaround is to speed up node 2 actions so they end before node 1 actions end.
@param cleanup True if all running actions and callbacks on the child node will be cleanup, false otherwise.
virtual void removeChild(Node* child, bool cleanup = true);
But, I made some tests and it looks like it is issue with my code (yep, I am not so surprised :P) - somewhere my node gets additional ref count (too many things at the same time are happening… diging it ;).
I am working on some general solution. Shortly, I keep actions in vector. Sometime later, I run all the stored actions (with Spawn) on some node. Everything is fine and works well when actions are finished - removeChild cleans all and destructors are called. However, when actions were not finished they weren’t really removed. The problem was that actions were still referenced in the “vector”. When I clear the vector actions are removed properly (their ref count decreased) and then node may be removed properly because nothing refers to it. Uff… I even have a test case for that