Projects > cpp > Issues > Bug #3803

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

CCVector should not release object if it is not in the Vector

Bug #3803 [Closed]
unoave 2014-01-21 09:08 . Updated about 2 years ago

I believe CCVector should not release an object if object is not in the Vector.

So the code below:

void eraseObject(T object, bool toRelease = true)
{
        CCASSERT(object != nullptr, "The object should not be nullptr");
        auto iter = std::find(_data.begin(), _data.end(), object);
        if (iter != _data.end())
            _data.erase(iter);
        if (toRelease)
            object->release();
}

should be changed to:
void eraseObject(T object, bool toRelease = true)
{
        CCASSERT(object != nullptr, "The object should not be nullptr");
        auto iter = std::find(_data.begin(), _data.end(), object);
        if (iter != _data.end()){
            _data.erase(iter);
            if (toRelease)
               object->release();
        }
}
ricardo 2014-01-21 17:23

yes, I think you are right.

walzer@cocos2d-x.org 2014-10-08 02:46

Redmine issue system is closed, we are using github issue system instead.

This issue was moved to https://github.com/cocos2d/cocos2d-x/issues/8322

Atom PDF

Status:Closed
Start date:2014-01-21
Priority:Low
Due date:
Assignee:-
% Done:

0%

Category:all
Target version:-

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.