[commands] add GraphModification on RemoveNode.undo

Avoid multiple graph updates on node/edges creation
This commit is contained in:
Yann Lanthony 2017-11-28 22:37:48 +01:00
parent 1a6febb02e
commit 06303c5773

View file

@ -4,7 +4,7 @@ from contextlib import contextmanager
from PySide2.QtWidgets import QUndoCommand, QUndoStack from PySide2.QtWidgets import QUndoCommand, QUndoStack
from PySide2.QtCore import Property, Signal from PySide2.QtCore import Property, Signal
from meshroom.core.graph import Node, ListAttribute, Graph from meshroom.core.graph import Node, ListAttribute, Graph, GraphModification
class UndoCommand(QUndoCommand): class UndoCommand(QUndoCommand):
@ -112,14 +112,15 @@ class RemoveNodeCommand(GraphCommand):
return True return True
def undoImpl(self): def undoImpl(self):
node = self.graph.addNode(Node(nodeDesc=self.nodeDict["nodeType"], with GraphModification(self.graph):
**self.nodeDict["attributes"] node = self.graph.addNode(Node(nodeDesc=self.nodeDict["nodeType"],
), self.nodeName) **self.nodeDict["attributes"]
assert (node.getName() == self.nodeName) ), self.nodeName)
# recreate out edges deleted on node removal assert (node.getName() == self.nodeName)
for dstAttr, srcAttr in self.outEdges.items(): # recreate out edges deleted on node removal
self.graph.addEdge(self.graph.attribute(srcAttr), for dstAttr, srcAttr in self.outEdges.items():
self.graph.attribute(dstAttr)) self.graph.addEdge(self.graph.attribute(srcAttr),
self.graph.attribute(dstAttr))
class SetAttributeCommand(GraphCommand): class SetAttributeCommand(GraphCommand):