Projects > cpp > Issues > Bug #3695

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

Create Issue on Github

ActionManagerEx::initWithDictionary error cause can not initWithDictionary again

Bug #3695 [Closed]
zzzzzzzzz04 2014-01-14 04:10 . Updated about 9 years ago

in the function “void ActionManagerEx::initWithDictionary”

*actionDic is unordered_map, this is unordered_map’s insert explain:
Each element is inserted only if its key is not equivalent to the key of any other element already in the container (keys in an unordered_map are unique).

so,when I run a scene,leave later,when I return the scene,*actionDic has have the same name vector now. can not insert success
but,ActionObject is depend on the node,node have release now .so play the action is crash.
_actionDic.insert(std::pair<std::string, cocos2d::Vector<ActionObject
>>(fileName, actionList));

add erase can resole the issue.

j1230xz 2014-06-04 09:26

A little too late but someone might find this use-full.
This problem still bugs me, so i did some research. This is a quick fix:

Add this to ActionManagerEx

void ActionManagerEx::releaseActions(const char* jsonName)
    std::string path = jsonName;
    ssize_t pos = path.find_last_of("/");
    std::string fileName = path.substr(pos+1,path.length());

    std::unordered_map>::iterator iter;
    std::list toRemove;
    for (iter = _actionDic.begin(); iter != _actionDic.end(); iter++)
        auto strJsonName = iter->first;
        if(strcmp(strJsonName.c_str(), fileName.c_str()) == 0)
            cocos2d::Vector objList = iter->second;

    for(auto item : toRemove)

Then open CCSGUIReader.cpp and add this

on line 970 in WidgetPropertiesReader0300::createWidget method (this is for cocos2d-x 3.0, check Other properties reader for other versions)

_actionDic.erase(_actionDic.find(item), _actionDic.end());
changed to
_actionDic.erase(_actionDic.find(item)); 2014-10-08 02:54

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

This issue was moved to

Atom PDF

Start date:2014-01-14
Due date:
% Done:


Target version:-