[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49608] trunk/blender/source/blender/ editors/space_node/node_group.c: Fix #32271, Node group/parent crash.
Lukas Toenne
lukas.toenne at googlemail.com
Mon Aug 6 13:23:10 CEST 2012
Revision: 49608
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49608
Author: lukastoenne
Date: 2012-08-06 11:23:09 +0000 (Mon, 06 Aug 2012)
Log Message:
-----------
Fix #32271, Node group/parent crash. The grouping operators need to also look at the non-selected nodes in the edit tree to find nodes whose parent is to be moved but the child is not, and then detach those.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_node/node_group.c
Modified: trunk/blender/source/blender/editors/space_node/node_group.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_group.c 2012-08-06 10:13:49 UTC (rev 49607)
+++ trunk/blender/source/blender/editors/space_node/node_group.c 2012-08-06 11:23:09 UTC (rev 49608)
@@ -631,45 +631,50 @@
/* add selected nodes into the ntree */
for (node = ngroup->nodes.first; node; node = node_next) {
node_next = node->next;
- if (!(node->flag & NODE_SELECT))
- continue;
-
- if (make_copy) {
- /* make a copy */
- newnode = nodeCopyNode(ngroup, node);
+ if (node->flag & NODE_SELECT) {
+
+ if (make_copy) {
+ /* make a copy */
+ newnode = nodeCopyNode(ngroup, node);
+ }
+ else {
+ /* use the existing node */
+ newnode = node;
+ }
+
+ /* keep track of this node's RNA "base" path (the part of the path identifying the node)
+ * if the old nodetree has animation data which potentially covers this node
+ */
+ if (ngroup->adt) {
+ PointerRNA ptr;
+ char *path;
+
+ RNA_pointer_create(&ngroup->id, &RNA_Node, newnode, &ptr);
+ path = RNA_path_from_ID_to_struct(&ptr);
+
+ if (path)
+ BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+ }
+
+ /* ensure valid parent pointers, detach if parent stays inside the group */
+ if (newnode->parent && !(newnode->parent->flag & NODE_SELECT))
+ nodeDetachNode(newnode);
+
+ /* migrate node */
+ BLI_remlink(&ngroup->nodes, newnode);
+ BLI_addtail(&ntree->nodes, newnode);
+
+ /* ensure unique node name in the node tree */
+ nodeUniqueName(ntree, newnode);
+
+ newnode->locx += gnode->locx;
+ newnode->locy += gnode->locy;
}
else {
- /* use the existing node */
- newnode = node;
+ /* ensure valid parent pointers, detach if child stays inside the group */
+ if (node->parent && (node->parent->flag & NODE_SELECT))
+ nodeDetachNode(node);
}
-
- /* keep track of this node's RNA "base" path (the part of the path identifying the node)
- * if the old nodetree has animation data which potentially covers this node
- */
- if (ngroup->adt) {
- PointerRNA ptr;
- char *path;
-
- RNA_pointer_create(&ngroup->id, &RNA_Node, newnode, &ptr);
- path = RNA_path_from_ID_to_struct(&ptr);
-
- if (path)
- BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
- }
-
- /* ensure valid parent pointers, detach if parent stays inside the group */
- if (newnode->parent && !(newnode->parent->flag & NODE_SELECT))
- nodeDetachNode(newnode);
-
- /* migrate node */
- BLI_remlink(&ngroup->nodes, newnode);
- BLI_addtail(&ntree->nodes, newnode);
-
- /* ensure unique node name in the node tree */
- nodeUniqueName(ntree, newnode);
-
- newnode->locx += gnode->locx;
- newnode->locy += gnode->locy;
}
/* add internal links to the ntree */
@@ -913,6 +918,11 @@
node->locx -= 0.5f * (min[0] + max[0]);
node->locy -= 0.5f * (min[1] + max[1]);
}
+ else {
+ /* if the parent is to be inserted but not the child, detach properly */
+ if (node->parent && (node->parent->flag & NODE_SELECT))
+ nodeDetachNode(node);
+ }
}
/* move animation data over */
More information about the Bf-blender-cvs
mailing list