From 4a4916db459cfe9edb7a67a1d8183e56fd115b47 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 28 Feb 2024 11:35:32 +0100 Subject: [PATCH] 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 --- source/blender/makesrna/intern/rna_node_socket.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/makesrna/intern/rna_node_socket.cc b/source/blender/makesrna/intern/rna_node_socket.cc index 592eed23752..4077d67b4ac 100644 --- a/source/blender/makesrna/intern/rna_node_socket.cc +++ b/source/blender/makesrna/intern/rna_node_socket.cc @@ -263,6 +263,10 @@ static void rna_NodeSocket_type_set(PointerRNA *ptr, int value) bNodeSocket *sock = static_cast(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); }