Page MenuHome

Fix T89415: Update multi input indices after deleting a node
ClosedPublic

Authored by Wannes Malfait (Wannes) on Jun 26 2021, 5:51 PM.

Details

Summary

When deleting a node, links attached to that node are deleted, but if one
of those links was connected to a multi input socket, the indices of the
other links connected to it were not updated. This adds updates both in
the case of a normal delete, as well as after a delete with reconnect.

Diff Detail

Repository
rB Blender
Branch
multi_input_indices (branched from master)
Build Status
Buildable 15985
Build 15985: arc lint + arc unit

Event Timeline

Wannes Malfait (Wannes) requested review of this revision.Jun 26 2021, 5:51 PM
Wannes Malfait (Wannes) created this revision.
Wannes Malfait (Wannes) added a project: Nodes.
Wannes Malfait (Wannes) retitled this revision from Fix T89453: Update multi input indices after deleting a node to Fix T89415: Update multi input indices after deleting a node.
Fabian Schempp (fabian_schempp) requested changes to this revision.Jun 27 2021, 10:05 AM

Thanks for working on that. So far it looks good to me. Just a tiny cleanup and a question.

source/blender/blenkernel/intern/node.cc
2523

Only from curiosity. When in the deleting process is this function called when nodeUnlinkNode is not? I just ask because (without knowing the details) it seems that nodeUnlinkNode iterates over all links in the tree. So maybe it's enough to adjust indices there?

source/blender/editors/space_node/node_edit.cc
1836 ↗(On Diff #38787)

unrelated change?

This revision now requires changes to proceed.Jun 27 2021, 10:05 AM
Wannes Malfait (Wannes) marked 2 inline comments as done.
  • Cleanup: undo accidental line removal
source/blender/blenkernel/intern/node.cc
2523

This happens in delete with reconnect (CTRL + X). The nodeInternalRelink function tries to merge a link going into the node to one going out of the node to be deleted. If there is no ingoing link, it deletes the outgoing link, which is why the nodeUnlinkNode function doesn't see that link anymore, and the update has to happen here.

I noticed this by accident when pressing ctrl+x instead of x while testing and saw that the update didn't happen.

This revision is now accepted and ready to land.Jun 29 2021, 10:12 PM
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/blenkernel/intern/node.cc
2519

What does this assert protect against? I wonder if we would loose anything by just not having it.

source/blender/blenkernel/intern/node.cc
2519

I think I added that mainly as an insurance that my logic was correct while testing, and just thought that it might be nice to leave it there. But realistically this can only fail if deleted_index <0, which would indicate an error somewhere else in the code, which should not be checked for here. So I think it's fine to just remove it.

  • Cleanup: remove unnecessary assert
Wannes Malfait (Wannes) marked an inline comment as done.Jul 23 2021, 11:45 AM