Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2012-08-06 15:23:09 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-08-06 15:23:09 +0400
commit54b61401edee7e4a26bf49b4d1f03c32af1cafc3 (patch)
treecb575a66be0a6a8da27a7ace6525d906e1e679f2 /source/blender/editors/space_node/node_group.c
parent2988c81d6b1edc1646a7b045b1ea7b3ea8f9db39 (diff)
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.
Diffstat (limited to 'source/blender/editors/space_node/node_group.c')
-rw-r--r--source/blender/editors/space_node/node_group.c82
1 files changed, 46 insertions, 36 deletions
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index 7d3c9ce6b5b..efd2378bf31 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -631,45 +631,50 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make
/* 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;
- }
-
- /* 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 child stays inside the group */
+ if (node->parent && (node->parent->flag & NODE_SELECT))
+ nodeDetachNode(node);
}
-
- /* 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 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode)
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 */