Page MenuHome

Fix T102740: Don't insert the group into itself
ClosedPublic

Authored by Iliya Katueshenock (Moder) on Nov 24 2022, 1:41 PM.

Details

Summary

This patch adds pre-validation of selected nodes by the insert operator to the group to not allow the group to be inserted into itself.

Diff Detail

Event Timeline

Iliya Katueshenock (Moder) requested review of this revision.Nov 24 2022, 1:41 PM
Iliya Katueshenock (Moder) created this revision.
Iliya Katueshenock (Moder) retitled this revision from Fix T102740: Haven't insert group into itself to Fix T102740: Don't insert the group into yourself.
Iliya Katueshenock (Moder) retitled this revision from Fix T102740: Don't insert the group into yourself to Fix T102740: Don't insert the group into itself.Nov 24 2022, 1:56 PM
Iliya Katueshenock (Moder) planned changes to this revision.Nov 26 2022, 11:43 PM
  • Move if (gnode->id) above, out of loop
source/blender/editors/space_node/node_group.cc
686

Is this redundant with the check below?

source/blender/editors/space_node/node_group.cc
686

This is for a separate, slightly different bug report.

But, if necessary, I planned to move node_group_make_node_tree_is_contains function to ED_node for the python api in the future. In such a case, this function could generate a text version of the message about how the groups overlap. For example Can not insert group Group.005 in Group.001 becouse Group.001->Group.002->Group.003->Group.004->Group.005

No need to make this more complex now. Generally seems good. Will test tomorrow. The function names could probably be improved.

Iliya Katueshenock (Moder) marked an inline comment as done.

I cleaned it up a bit more, does this make sense to you: P3359?

I wanted to make sure that there is no unnecessary check, but I didn’t even think about reusing node_group_make_node.

I will need to remember reinterpret_cast so I don't run into problems (tried to use static cast at first but didn't work)

Still, I think it's better to agree with your naming / commenting option. At least in the formulation of an understandable comment, I'm definitely weak

  • Merge master
  • This is a slightly specific operation. In the new approach to the insert test, it is more logical to raise this check to an insert statement, since the extra call to create a new group is redundant.

One comment inline, other than that this looks good, thanks.

source/blender/editors/space_node/node_group.cc
1204–1211

IMO it's a bit clearer if there's just a if (node->is_group() && node->id) { check inside this look, that saves creating the temporary set (and having to come up with a name for it, and having to use brackets to make a separate scope for it).

Iliya Katueshenock (Moder) marked an inline comment as done.
source/blender/editors/space_node/node_group.cc
1200

This if statement seems weird to me. It looks like it's checking "if the node isn't a group node or it doesn't have a data-block" which doesn't sound right. I'd think this should check "if the node is a group node and it has a data-block, which is the check I posted in my previous comment. Am I missing something?

Hans Goudey (HooglyBoogly) added inline comments.
source/blender/editors/space_node/node_group.cc
1200

Oops, I misread this!

This revision is now accepted and ready to land.Dec 5 2022, 4:46 PM
Iliya Katueshenock (Moder) marked 2 inline comments as done.Dec 13 2022, 9:09 PM