Hi there, can you make the line in replace()
method in cocos2d::Vector()
something like this?
/** Replace value at index with given object. */
void replace(ssize_t index, T object)
{
CCASSERT(index >= 0 && index < size(), "Invalid index!");
CCASSERT(object != nullptr, "The object should not be nullptr");
if(_data[index] != nullptr) _data[index]->release(); //<--REQUEST
//_data[index]->release(); //original line
_data[index] = object;
object->retain();
}
My reason is, there will be cases where you need an empty array first then add contents to it in non-sequential order later.
I have one of this case in my current project but I made an alternate solution so it’s ok now. But I think it’s better if to update the line of code that way for future releases.