mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-20 20:46:28 +02:00
Store all duplicates of a node correctly upon their creation
Duplicates used to be stored in a dictionary with an entry being "parent node": "duplicated node". On occasions where a single parent node was duplicated more than once, the latest duplicated node erased the previous one(s), and these older ones were "lost": after being created, there was no trace left of their existence in the duplication operation. Undoing that duplication operation was thus leaving these duplicated nodes out and not removing them. Duplicated nodes are now stored as "parent node": [list of duplicated nodes] to keep track of all the created nodes, effectively removing them upon an "undo".
This commit is contained in:
parent
09fc117c65
commit
b77274a027
3 changed files with 17 additions and 12 deletions
|
@ -266,14 +266,16 @@ def test_duplicate_nodes():
|
|||
# duplicate from n1
|
||||
nodes_to_duplicate, _ = g.dfsOnDiscover(startNodes=[n1], reverse=True, dependenciesOnly=True)
|
||||
nMap = g.duplicateNodes(srcNodes=nodes_to_duplicate)
|
||||
for s, d in nMap.items():
|
||||
assert s.nodeType == d.nodeType
|
||||
for s, duplicated in nMap.items():
|
||||
for d in duplicated:
|
||||
assert s.nodeType == d.nodeType
|
||||
|
||||
# check number of duplicated nodes
|
||||
assert len(nMap) == 3
|
||||
# check number of duplicated nodes and that every parent node has been duplicated once
|
||||
assert len(nMap) == 3 and all([len(nMap[i]) == 1 for i in nMap.keys()])
|
||||
|
||||
# check connections
|
||||
assert nMap[n1].input.getLinkParam() == n0.output
|
||||
assert nMap[n2].input.getLinkParam() == nMap[n1].output
|
||||
assert nMap[n3].input.getLinkParam() == nMap[n1].output
|
||||
assert nMap[n3].input2.getLinkParam() == nMap[n2].output
|
||||
# access directly index 0 because we know there is a single duplicate for each parent node
|
||||
assert nMap[n1][0].input.getLinkParam() == n0.output
|
||||
assert nMap[n2][0].input.getLinkParam() == nMap[n1][0].output
|
||||
assert nMap[n3][0].input.getLinkParam() == nMap[n1][0].output
|
||||
assert nMap[n3][0].input2.getLinkParam() == nMap[n2][0].output
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue