mirror of https://github.com/axmolengine/axmol.git
closed #4054: Removing child from TMXLayer may cause crash.
This commit is contained in:
parent
e550ff7741
commit
19b1945efb
|
@ -541,8 +541,9 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite)
|
||||||
{
|
{
|
||||||
auto next = std::next(it);
|
auto next = std::next(it);
|
||||||
|
|
||||||
|
Sprite *spr = nullptr;
|
||||||
for(; next != _descendants.end(); ++next) {
|
for(; next != _descendants.end(); ++next) {
|
||||||
Sprite *spr = *next;
|
spr = *next;
|
||||||
spr->setAtlasIndex( spr->getAtlasIndex() - 1 );
|
spr->setAtlasIndex( spr->getAtlasIndex() - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,10 +650,11 @@ SpriteBatchNode * SpriteBatchNode::addSpriteWithoutQuad(Sprite*child, int z, int
|
||||||
child->setAtlasIndex(z);
|
child->setAtlasIndex(z);
|
||||||
|
|
||||||
// XXX: optimize with a binary search
|
// XXX: optimize with a binary search
|
||||||
auto it = std::begin(_descendants);
|
auto it = _descendants.begin();
|
||||||
for(const auto &sprite: _descendants) {
|
for (; it != _descendants.end(); ++it)
|
||||||
if(sprite->getAtlasIndex() >= z)
|
{
|
||||||
std::next(it);
|
if((*it)->getAtlasIndex() >= z)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_descendants.insert(it, child);
|
_descendants.insert(it, child);
|
||||||
|
|
Loading…
Reference in New Issue