mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-13 23:07:21 +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
|
@ -382,7 +382,7 @@ class Graph(BaseObject):
|
|||
node, edges = self.copyNode(srcNode, withEdges=False)
|
||||
duplicate = self.addNode(node)
|
||||
duplicateEdges.update(edges)
|
||||
duplicates[srcNode] = duplicate # original node to duplicate map
|
||||
duplicates.setdefault(srcNode, []).append(duplicate)
|
||||
|
||||
# re-create edges taking into account what has been duplicated
|
||||
for attr, linkExpression in duplicateEdges.items():
|
||||
|
@ -390,8 +390,10 @@ class Graph(BaseObject):
|
|||
# get source node and attribute name
|
||||
edgeSrcNodeName, edgeSrcAttrName = link.split(".", 1)
|
||||
edgeSrcNode = self.node(edgeSrcNodeName)
|
||||
# if the edge's source node has been duplicated, use the duplicate; otherwise use the original node
|
||||
edgeSrcNode = duplicates.get(edgeSrcNode, edgeSrcNode)
|
||||
# if the edge's source node has been duplicated (the key exists in the dictionary),
|
||||
# use the duplicate; otherwise use the original node
|
||||
if edgeSrcNode in duplicates:
|
||||
edgeSrcNode = duplicates.get(edgeSrcNode)[0]
|
||||
self.addEdge(edgeSrcNode.attribute(edgeSrcAttrName), attr)
|
||||
|
||||
return duplicates
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue