Commit: e8777a729013d04dcb854b0b9f327e9b90191747
Author: Bastien Montagne
Date:   Tue Mar 19 14:43:14 2019 +0100
Branches: master
https://developer.blender.org/rBe8777a729013d04dcb854b0b9f327e9b90191747

Fix T62732: Bpy/Python is letting create inputs at the node level for node 
groups that make blend file unsaveable.

Group nodes should not allow to add IO sockets to themselves directly,
in that case we actually want to add IO sockets to their underlying
node tree. Fairly straioght forward to support actually.

===================================================================

M       source/blender/makesrna/intern/rna_nodetree.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index 248a1486d48..7bd3d5e9b9c 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1619,6 +1619,11 @@ static void rna_Node_name_set(PointerRNA *ptr, const 
char *value)
 
 static bNodeSocket *rna_Node_inputs_new(ID *id, bNode *node, Main *bmain, 
ReportList *reports, const char *type, const char *name, const char *identifier)
 {
+       /* Adding an input to a group node is not working, simpler to add it to 
its underlying nodetree. */
+       if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id != 
NULL) {
+               return rna_NodeTree_inputs_new((bNodeTree *)node->id, bmain, 
reports, type, name);
+       }
+
        bNodeTree *ntree = (bNodeTree *)id;
        bNodeSocket *sock;
 
@@ -1637,6 +1642,11 @@ static bNodeSocket *rna_Node_inputs_new(ID *id, bNode 
*node, Main *bmain, Report
 
 static bNodeSocket *rna_Node_outputs_new(ID *id, bNode *node, Main *bmain, 
ReportList *reports, const char *type, const char *name, const char *identifier)
 {
+       /* Adding an output to a group node is not working, simpler to add it 
to its underlying nodetree. */
+       if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id != 
NULL) {
+               return rna_NodeTree_outputs_new((bNodeTree *)node->id, bmain, 
reports, type, name);
+       }
+
        bNodeTree *ntree = (bNodeTree *)id;
        bNodeSocket *sock;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to