Fix parent children indexer get logic

This commit is contained in:
halx99 2021-11-07 17:08:54 +08:00
parent e30cfe0de3
commit 402f106d7f
1 changed files with 8 additions and 5 deletions

View File

@ -725,11 +725,14 @@ NodeIndexerMap_t* Node::getParentChildrenIndexer()
if (!_director->isChildrenIndexerEnabled())
return nullptr;
auto parent = getParent();
NodeIndexerMap_t* indexer = nullptr;
if (parent && !parent->_childrenIndexer)
indexer = parent->_childrenIndexer = new NodeIndexerMap_t();
return indexer;
if (parent)
{
auto& indexer = parent->_childrenIndexer;
if (!indexer)
indexer = new NodeIndexerMap_t();
return indexer;
}
return nullptr;
}
/// userData setter