Fix T38075, crash from shader node add/replace tree view template.

The sanity check for copying socket default value was using the socket
idname for type compatibility checks, which is too strict. Subtypes
would not be recognized as copyable, but since only the plain data type
is needed below this is all that needs to be checked.

That alone would not cause crash (just missing default value copy),
but the tree view template was messing with the default_value DNA
directly by freeing it in advance, which is not necessary and should
be left to blenkernel when freeing the node. Otherwise this would
leave the node invalid without a default_value if the copy function
bails out.
This commit is contained in:
Lukas Tönne 2014-01-07 10:54:31 +01:00
parent 54ebaad377
commit ebf23b5144
Notes: blender-bot 2023-02-14 11:23:56 +01:00
Referenced by issue #38075, changing cycles material from current to glass in materials editor causes blender to close
2 changed files with 1 additions and 5 deletions

View File

@ -246,10 +246,6 @@ static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode *
nodeRemLink(ntree, link);
}
if (sock_from->default_value) {
MEM_freeN(sock_from->default_value);
sock_from->default_value = NULL;
}
node_socket_copy_default_value(sock_from, sock_prev);
}
}

View File

@ -273,7 +273,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
void node_socket_copy_default_value(bNodeSocket *to, bNodeSocket *from)
{
/* sanity check */
if (!STREQ(to->idname, from->idname))
if (to->type != from->type)
return;
/* make sure both exist */