Cleanup: Return early for null check

This commit is contained in:
Hans Goudey 2021-12-10 16:42:16 -06:00
parent a8b730e04c
commit 1a02c0d7dd
1 changed files with 31 additions and 32 deletions

View File

@ -3418,40 +3418,39 @@ void ntreeNodeFlagSet(const bNodeTree *ntree, const int flag, const bool enable)
bNodeTree *ntreeLocalize(bNodeTree *ntree)
{
if (ntree) {
/* Make full copy outside of Main database.
* NOTE: previews are not copied here.
*/
bNodeTree *ltree = (bNodeTree *)BKE_id_copy_ex(
nullptr, &ntree->id, nullptr, (LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA));
ltree->id.tag |= LIB_TAG_LOCALIZED;
LISTBASE_FOREACH (bNode *, node, &ltree->nodes) {
if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) {
node->id = (ID *)ntreeLocalize((bNodeTree *)node->id);
}
}
/* ensures only a single output node is enabled */
ntreeSetOutput(ntree);
bNode *node_src = (bNode *)ntree->nodes.first;
bNode *node_local = (bNode *)ltree->nodes.first;
while (node_src != nullptr) {
node_local->original = node_src;
node_src = node_src->next;
node_local = node_local->next;
}
if (ntree->typeinfo->localize) {
ntree->typeinfo->localize(ltree, ntree);
}
return ltree;
if (ntree == nullptr) {
return nullptr;
}
return nullptr;
/* Make full copy outside of Main database.
* NOTE: previews are not copied here. */
bNodeTree *ltree = (bNodeTree *)BKE_id_copy_ex(
nullptr, &ntree->id, nullptr, (LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA));
ltree->id.tag |= LIB_TAG_LOCALIZED;
LISTBASE_FOREACH (bNode *, node, &ltree->nodes) {
if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) {
node->id = (ID *)ntreeLocalize((bNodeTree *)node->id);
}
}
/* ensures only a single output node is enabled */
ntreeSetOutput(ntree);
bNode *node_src = (bNode *)ntree->nodes.first;
bNode *node_local = (bNode *)ltree->nodes.first;
while (node_src != nullptr) {
node_local->original = node_src;
node_src = node_src->next;
node_local = node_local->next;
}
if (ntree->typeinfo->localize) {
ntree->typeinfo->localize(ltree, ntree);
}
return ltree;
}
void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree)