From df0616bcd0c3d2a020a36c573b4df49c9947c949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Sun, 1 May 2022 09:27:22 +0100 Subject: Nodes: Fix T90233 - Fix default_value initialization of custom node tree interface: This was crashing when adding a custom interface socket to a tree. The node_socket_set_typeinfo function was called too early, creating a default float socket, which then doesn't match the socket type after changing to the custom type. The node_socket_set_typeinfo only allocates and initializes default_value when it isn't already set. That is because the function is used either when creating new sockets or to initialize typeinfo after loading files. So default_value has to be either null or has to be matching the current type already. - Fix RNA flag for string return value of the valid_socket_type callback: String return values of registerable RNA functions need a PROP_THICK_WRAP flag since they don't have a fixed buffer to write into. --- source/blender/blenkernel/intern/node.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index d3f61d381f2..200eefb73ec 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -1165,6 +1165,9 @@ static void node_set_typeinfo(const struct bContext *C, } } +/* Warning: default_value must either be null or match the typeinfo at this point. + * This function is called both for initializing new sockets and after loading files. + */ static void node_socket_set_typeinfo(bNodeTree *ntree, bNodeSocket *sock, bNodeSocketType *typeinfo) @@ -3286,9 +3289,9 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree, bNodeSocket *sock = MEM_cnew("socket template"); BLI_strncpy(sock->idname, stype->idname, sizeof(sock->idname)); - node_socket_set_typeinfo(ntree, sock, stype); sock->in_out = in_out; sock->type = SOCK_CUSTOM; /* int type undefined by default */ + node_socket_set_typeinfo(ntree, sock, stype); /* assign new unique index */ const int own_index = ntree->cur_index++; -- cgit v1.2.3