Cleanup: Nodes: Remove always-null arguments

Pull Request: https://projects.blender.org/blender/blender/pulls/139505
This commit is contained in:
Hans Goudey
2025-05-27 23:05:38 +02:00
committed by Hans Goudey
parent 0e7a696819
commit e19fead49d
4 changed files with 15 additions and 16 deletions

View File

@@ -546,7 +546,7 @@ Span<bNodeTreeType *> node_tree_types_get();
* In that case the update_typeinfo function will set type-info on registration
* and do necessary updates.
*/
void node_tree_set_type(const bContext *C, bNodeTree &ntree);
void node_tree_set_type(bNodeTree &ntree);
bNodeTree *node_tree_add_tree(Main *bmain, StringRef name, StringRef idname);

View File

@@ -2104,7 +2104,7 @@ static void ntree_blend_read_after_liblink(BlendLibReader *reader, ID *id)
* first versioning that can change types still without functions that
* update the `typeinfo` pointers. Versioning after lib linking needs
* these top be valid. */
node_tree_set_type(nullptr, *ntree);
node_tree_set_type(*ntree);
/* For nodes with static socket layout, add/remove sockets as needed
* to match the static layout. */
@@ -2380,7 +2380,6 @@ static void node_socket_set_typeinfo(bNodeTree *ntree,
/* Set specific typeinfo pointers in all node trees on register/unregister */
static void update_typeinfo(Main *bmain,
const bContext *C,
bNodeTreeType *treetype,
bNodeType *nodetype,
bNodeSocketType *socktype,
@@ -2398,7 +2397,7 @@ static void update_typeinfo(Main *bmain,
/* initialize nodes */
for (bNode *node : ntree->all_nodes()) {
if (nodetype && node->idname == nodetype->idname) {
node_set_typeinfo(C, ntree, node, unregister ? nullptr : nodetype);
node_set_typeinfo(nullptr, ntree, node, unregister ? nullptr : nodetype);
}
/* initialize node sockets */
@@ -2417,7 +2416,7 @@ static void update_typeinfo(Main *bmain,
FOREACH_NODETREE_END;
}
void node_tree_set_type(const bContext *C, bNodeTree &ntree)
void node_tree_set_type(bNodeTree &ntree)
{
ntree_set_typeinfo(&ntree, node_tree_type_find(ntree.idname));
@@ -2431,7 +2430,7 @@ void node_tree_set_type(const bContext *C, bNodeTree &ntree)
node_socket_set_typeinfo(&ntree, sock, node_socket_type_find(sock->idname));
}
node_set_typeinfo(C, &ntree, node, node_type_find(node->idname));
node_set_typeinfo(nullptr, &ntree, node, node_type_find(node->idname));
}
}
@@ -2509,7 +2508,7 @@ void node_tree_type_add(bNodeTreeType &nt)
/* XXX pass Main to register function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, nullptr, &nt, nullptr, nullptr, false);
update_typeinfo(G_MAIN, &nt, nullptr, nullptr, false);
}
static void ntree_free_type(void *treetype_v)
@@ -2518,11 +2517,11 @@ static void ntree_free_type(void *treetype_v)
/* XXX pass Main to unregister function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, nullptr, treetype, nullptr, nullptr, true);
update_typeinfo(G_MAIN, treetype, nullptr, nullptr, true);
/* Defer freeing the tree type, because it may still be referenced by trees in depsgraph
* copies. We can't just remove these tree types, because the depsgraph may exist completely
* separate from original data. */
* separately from original data. */
defer_free_tree_type(treetype);
}
@@ -2566,7 +2565,7 @@ static void node_free_type(void *nodetype_v)
/* XXX pass Main to unregister function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, nullptr, nullptr, nodetype, nullptr, true);
update_typeinfo(G_MAIN, nullptr, nodetype, nullptr, true);
/* Setting this to null is necessary for the case of static node types. When running tests,
* they may be registered and unregistered multiple times. */
@@ -2601,7 +2600,7 @@ void node_register_type(bNodeType &nt)
/* XXX pass Main to register function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, nullptr, nullptr, &nt, nullptr, false);
update_typeinfo(G_MAIN, nullptr, &nt, nullptr, false);
}
void node_unregister_type(bNodeType &nt)
@@ -2649,7 +2648,7 @@ static void node_free_socket_type(void *socktype_v)
/* XXX pass Main to unregister function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, nullptr, nullptr, nullptr, socktype, true);
update_typeinfo(G_MAIN, nullptr, nullptr, socktype, true);
/* Defer freeing the socket type, because it may still be referenced by nodes in depsgraph
* copies. We can't just remove these socket types, because the depsgraph may exist completely
@@ -2663,7 +2662,7 @@ void node_register_socket_type(bNodeSocketType &st)
/* XXX pass Main to register function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, nullptr, nullptr, nullptr, &st, false);
update_typeinfo(G_MAIN, nullptr, nullptr, &st, false);
}
void node_unregister_socket_type(bNodeSocketType &st)

View File

@@ -1449,7 +1449,7 @@ void blo_do_versions_270(FileData *fd, Library * /*lib*/, Main *bmain)
if (!DNA_struct_member_exists(fd->filesdna, "NodeGlare", "char", "star_45")) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
blender::bke::node_tree_set_type(nullptr, *ntree);
blender::bke::node_tree_set_type(*ntree);
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type_legacy == CMP_NODE_GLARE) {
NodeGlare *ndg = static_cast<NodeGlare *>(node->storage);
@@ -1601,7 +1601,7 @@ void do_versions_after_linking_270(Main *bmain)
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 279, 0)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
blender::bke::node_tree_set_type(nullptr, *ntree);
blender::bke::node_tree_set_type(*ntree);
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type_legacy == CMP_NODE_HUE_SAT) {
do_version_hue_sat_node(ntree, node);

View File

@@ -681,7 +681,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt
using namespace blender;
using namespace blender::bke;
/* Otherwise `ntree->typeInfo` is null. */
blender::bke::node_tree_set_type(nullptr, *ntree);
blender::bke::node_tree_set_type(*ntree);
LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) {
if (node->type_legacy != GEO_NODE_TRANSFER_ATTRIBUTE_DEPRECATED) {
continue;