Here’s my version of cocos2d-x:
cocos2d-2.1beta3-x-2.1.0
method: ccbAnimationManager ~~> setDelegate
description: this will retain your delegate. if your delegate happen to be the node itself, than it will never be destoryed.
solution: remove the retain or setDelegate on onExit method.
<pre>
</pre>
void CCBAnimationManager::setDelegate
{
//CC_SAFE_RELEASE);
mDelegate = pDelegate;
//CC_SAFE_RETAIN);
}
method: ccbAnimationManager~~> setRootNode
description: this will be invoke automatically, so normally your ccb object will born un-releasable
solution:
void CCBAnimationManager::setRootNode(CCNode *pRootNode)
{
//CC_SAFE_RELEASE(mRootNode);
mRootNode = pRootNode;
//CC_SAFE_RETAIN(mRootNode);
}
macro: CCBMemberVariableAssigner.h CCB_MEMBERVARIABLEASSIGNER_GLUE
description: every time you assign a ccnode to your class var, the node will be retain
solution: release all assigned var in onExit() method, or just modify the macro to
#define CCB_MEMBERVARIABLEASSIGNER_GLUE(TARGET, MEMBERVARIABLENAME, MEMBERVARIABLETYPE, MEMBERVARIABLE) \
if (pTarget == TARGET && 0 == strcmp(pMemberVariableName, (MEMBERVARIABLENAME))) { \
MEMBERVARIABLETYPE pOldVar = MEMBERVARIABLE; \
MEMBERVARIABLE = dynamic_cast(pNode); \
CC_ASSERT(MEMBERVARIABLE); \
if (pOldVar != MEMBERVARIABLE) { \
CC_SAFE_RELEASE(pOldVar); \
} \
return true; \
}
note: this will be quite similar to iOS native SDK to manually release the assigned outlets, but programmers needs to be taught to use it correctly
method: CCNode > CCNode>m_pParent = NULL;
description:\ CCNode\ doesn’t\ release\ all\ children\ correctly\ for\ some\ reason,\ so\ sometimes\ parents\ was\ released\ but\ children\ will\ not.\
solution:\ modify\ the\ CCNode.h
<pre>
CCNode
CCNode::
{
CCLOGINFO;
unregisterScriptHandler;
CC_SAFE_RELEASE;
CC_SAFE_RELEASE;
// attributes
CC_SAFE_RELEASE;
CC_SAFE_RELEASE;
CC_SAFE_RELEASE;
CC_SAFE_RELEASE;
removeAllChildren; //Add this
// if > 0)
// {
// CCObject* child;
// CCARRAY_FOREACH
// {
// CCNode* pChild = child;
// if
// {
// pChild
// }
// }
// }
//
// // children
// CC_SAFE_RELEASE(m_pChildren);
}