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:
Candice Bentéjac 2022-07-20 16:11:37 +02:00
parent 09fc117c65
commit b77274a027
3 changed files with 17 additions and 12 deletions

View file

@ -184,7 +184,8 @@ class DuplicateNodesCommand(GraphCommand):
def redoImpl(self):
srcNodes = [ self.graph.node(i) for i in self.srcNodeNames ]
duplicates = list(self.graph.duplicateNodes(srcNodes).values())
# flatten the list of duplicated nodes to avoid lists within the list
duplicates = [ n for nodes in list(self.graph.duplicateNodes(srcNodes).values()) for n in nodes ]
self.duplicates = [ n.name for n in duplicates ]
return duplicates