Fix T94416: incorrect handling when nodes are linked in a loop

This just skips the entire algorithm when there are cycles.
In the future, cycles could be handled more gracefully in the
algorithm, but for now that's not worth it and is not necessary
to fix the bug.
This commit is contained in:
Jacques Lucke 2021-12-31 11:33:47 +01:00
parent 71468f475b
commit 018272ee5b
Notes: blender-bot 2023-02-14 10:14:07 +01:00
Referenced by issue #94416, Possibly recursive freeze
1 changed files with 6 additions and 0 deletions

View File

@ -1366,6 +1366,11 @@ class NodeTreeMainUpdater {
uint32_t get_combined_socket_topology_hash(const NodeTreeRef &tree,
Span<const SocketRef *> sockets)
{
if (tree.has_link_cycles()) {
/* Return dummy value when the link has any cycles. The algorithm below could be improved to
* handle cycles more gracefully. */
return 0;
}
Array<uint32_t> hashes = this->get_socket_topology_hashes(tree, sockets);
uint32_t combined_hash = 0;
for (uint32_t hash : hashes) {
@ -1377,6 +1382,7 @@ class NodeTreeMainUpdater {
Array<uint32_t> get_socket_topology_hashes(const NodeTreeRef &tree,
Span<const SocketRef *> sockets)
{
BLI_assert(!tree.has_link_cycles());
Array<std::optional<uint32_t>> hash_by_socket_id(tree.sockets().size());
Stack<const SocketRef *> sockets_to_check = sockets;