Fix T104296: crash caused by incorrectly initialized group nodes
Versioning code in `do_versions_after_linking_260` inserted new group input and output nodes. And (reasonably?) expected sockets to exist on those nodes. However, `nodeAddStaticNode` did not initialize sockets on nodes with that use `declare_dynamic` yet. This patch changes it so that `declare_dynamic` is used in more places, which caused issues during file loading when node groups are updated in somewhat arbitrary order (not in an order that is based on which groups use which). Differential Revision: https://developer.blender.org/D17183
This commit is contained in:
@@ -922,7 +922,11 @@ void ntreeBlendReadLib(BlendLibReader *reader, bNodeTree *ntree)
|
||||
* to match the static layout. */
|
||||
if (!BLO_read_lib_is_undo(reader)) {
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
node_verify_sockets(ntree, node, false);
|
||||
/* Don't update node groups here because they may depend on other node groups which are not
|
||||
* fully versioned yet and don't have `typeinfo` pointers set. */
|
||||
if (node->type != NODE_GROUP) {
|
||||
node_verify_sockets(ntree, node, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1075,7 +1079,7 @@ IDTypeInfo IDType_ID_NT = {
|
||||
|
||||
static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType *ntype)
|
||||
{
|
||||
if (ntype->declare != nullptr) {
|
||||
if (ntype->declare || ntype->declare_dynamic) {
|
||||
node_verify_sockets(ntree, node, true);
|
||||
return;
|
||||
}
|
||||
@@ -3594,24 +3598,23 @@ void nodeSocketDeclarationsUpdate(bNode *node)
|
||||
update_socket_declarations(&node->outputs, node->runtime->declaration->outputs);
|
||||
}
|
||||
|
||||
bool nodeDeclarationEnsureOnOutdatedNode(bNodeTree * /*ntree*/, bNode *node)
|
||||
bool nodeDeclarationEnsureOnOutdatedNode(bNodeTree *ntree, bNode *node)
|
||||
{
|
||||
if (node->runtime->declaration != nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (node->typeinfo->declare == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (node->typeinfo->declare_dynamic) {
|
||||
node->runtime->declaration = new blender::nodes::NodeDeclaration();
|
||||
blender::nodes::build_node_declaration(*node->typeinfo, *node->runtime->declaration);
|
||||
blender::nodes::build_node_declaration_dynamic(*ntree, *node, *node->runtime->declaration);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (node->typeinfo->declare) {
|
||||
/* Declaration should have been created in #nodeRegisterType. */
|
||||
BLI_assert(node->typeinfo->fixed_declaration != nullptr);
|
||||
node->runtime->declaration = node->typeinfo->fixed_declaration;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool nodeDeclarationEnsure(bNodeTree *ntree, bNode *node)
|
||||
|
||||
@@ -283,7 +283,7 @@ void node_verify_sockets(bNodeTree *ntree, bNode *node, bool do_id_user)
|
||||
if (ntype == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (ntype->declare != nullptr) {
|
||||
if (ntype->declare || ntype->declare_dynamic) {
|
||||
nodeDeclarationEnsureOnOutdatedNode(ntree, node);
|
||||
refresh_node(*ntree, *node, *node->runtime->declaration, do_id_user);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user