Fix #118237: don't allow changing NodeSocket.type directly on built-in nodes

Changing socket types like this is not generally supported. Usually one should
modify a property that is stored on the node instead. For custom node trees,
one should generally remove one socket and replace it with the new one.

Existing addons might use this functionality on custom node trees where it's
okayish. This patch forbids changing socket types directly on built-in nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/118794
This commit is contained in:
Jacques Lucke
2024-02-28 11:35:32 +01:00
parent 4bc1ba3c2d
commit 4a4916db45

View File

@@ -263,6 +263,10 @@ static void rna_NodeSocket_type_set(PointerRNA *ptr, int value)
bNodeSocket *sock = static_cast<bNodeSocket *>(ptr->data);
bNode *node;
nodeFindNode(ntree, sock, &node, nullptr);
if (node->type != NODE_CUSTOM) {
/* Can't change the socket type on built-in nodes like this. */
return;
}
nodeModifySocketTypeStatic(ntree, node, sock, value, 0);
}