From fd24e1001a0e88db0c35a6dbcbbb1beadd799fd7 Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Mon, 30 Jun 2025 18:47:09 +0200 Subject: [PATCH] Refactor: Move contextual init before socket declaration Currently, the standard init function is called before socket declaration, but the contextual init function is called after, which is problematic if the declaration depends on the initialization step. This patch moves the contextual init function to be called before declaration just like the standard init function. This is needed when moving the File Output node to use socket declaration. Pull Request: https://projects.blender.org/blender/blender/pulls/141203 --- source/blender/blenkernel/intern/node.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 59677d764d6..a1f262cd5c0 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -1823,6 +1823,15 @@ static void node_init(const bContext *C, bNodeTree *ntree, bNode *node) ntype->initfunc(ntree, node); } + if (ntype->initfunc_api) { + PointerRNA ptr = RNA_pointer_create_discrete(&ntree->id, &RNA_Node, node); + + /* XXX WARNING: context can be nullptr in case nodes are added in do_versions. + * Delayed init is not supported for nodes with context-based `initfunc_api` at the moment. */ + BLI_assert(C != nullptr); + ntype->initfunc_api(C, &ptr); + } + if (ntree->typeinfo && ntree->typeinfo->node_add_init) { ntree->typeinfo->node_add_init(ntree, node); } @@ -1835,15 +1844,6 @@ static void node_init(const bContext *C, bNodeTree *ntree, bNode *node) id_us_plus(node->id); } - if (ntype->initfunc_api) { - PointerRNA ptr = RNA_pointer_create_discrete(&ntree->id, &RNA_Node, node); - - /* XXX WARNING: context can be nullptr in case nodes are added in do_versions. - * Delayed init is not supported for nodes with context-based `initfunc_api` at the moment. */ - BLI_assert(C != nullptr); - ntype->initfunc_api(C, &ptr); - } - node->flag |= NODE_INIT; }