I was working with CCArray and got to a double release of an object.
While scanning over the code I found out the CCArray copies itself like so:
`CCObject* CCArray::copyWithZone(CCZone* pZone)
CCAssert(pZone == NULL, "CCArray should not be inherited.");
CCArray* pArray = new CCArray();
pArray->initWithCapacity(this->data->num > 0 ? this->data->num : 1);
CCObject* pObj = NULL;
CCObject* pTmpObj = NULL;
pTmpObj = pObj->copy();
I underlined the line which is a bug.
You add the object to the array which retains it and then releases it
while, I guess, you assume that the “copy()” of the object retains it (which it may very well not, as in my case).
At first I thought that I missed some guidelines which says you have to retain on copy,
but after I could not find any I noticed that even the very same copy here does not use retain.
Some extra non-crucial, but related, ideas of mine:
1) pTmpObj is a terrible name for this object because it is really really not a temp, it is being added and kept in the array
2) If you for some unknown reason decide that retain is a must on copy then please just add a retain at CCObject::copy()
Thanks and have a nice day.
Working for a little while with cocos2d-x now and I am, so far, very satisfied.
Please keep up the good work, and I hope this contributed by some means.