Projects > cpp > Issues > Bug #341

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

Create Issue on Github

CCTMXFiledMap crashed when a child isnot the obj of CCTMXLayer

Bug #341 [Closed]
walzer@cocos2d-x.org 2011-01-30 18:27 . Updated over 4 years ago
CCTMXLayer * CCTMXTiledMap::layerNamed(const char *layerName)
    {
        std::string sLayerName = layerName;
        if (m_pChildren && m_pChildren->count()>0)
        {
            CCTMXLayer *layer;
            NSMutableArray::NSMutableArrayIterator it;
            for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
            {
                layer = (CCTMXLayer*)(*it);
                if (layer && layer->getLayerName() == sLayerName)
                {
                    return layer;
                }
            }
        }

        // layer not found
        return NULL;
    }

In these lines:

layer = (CCTMXLayer*)(*it);
if (layer && layer->getLayerName() == sLayerName)

The developer add in a child which isnot the type of CCTMXLayer*, so the program crashs at getLayerName()

walzer@cocos2d-x.org 2011-03-05 00:11
  • Target version set to 9
walzer@cocos2d-x.org 2011-04-08 23:38
  • Status changed from New to Accepted
  • Assignee set to zhangbin@cocos2d-x.org
  • Target version changed from 9 to cocos2d-0.99.5-x-0.8.3

Angelo Rohit give the proposed fix at http://www.cocos2d-x.org/boards/7/topics/1138
Please check it.

zhangbin@cocos2d-x.org 2011-04-12 02:17
  • Status changed from Accepted to Resolved
  • % Done changed from 0 to 100

Applied in changeset commit:8437b86c5540725d48279a63bc33eb87ffc14414.

zhangbin@cocos2d-x.org 2011-04-12 02:17

Applied in changeset commit:91e5406acc78f3e39d005f98108f50f6a5404cab.

zhangbin@cocos2d-x.org 2011-04-12 02:45
  • Category set to 5
  • Status changed from Resolved to Closed
walzer@cocos2d-x.org 2012-05-25 08:19
  • Project changed from cocos2d-x to cpp
  • Category deleted (5)
  • Target version deleted (cocos2d-0.99.5-x-0.8.3)

Atom PDF

Status:Closed
Start date:2011-01-30
Priority:Normal
Due date:
Assignee:zhangbin@cocos2d-x.org
% Done:

100%

Category:-
Target version:-

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