Skip to content

Commit

Permalink
[commands] UpgradeNode.undo: only set expected uid when "downgrading"…
Browse files Browse the repository at this point in the history
… UidConflict

Only set the expectedUid when undoing the upgrade of a uid conflicting node.
Otherwise, let the other type of conflicts take precedence.
  • Loading branch information
yann-lty committed Dec 13, 2024
1 parent 42550b6 commit 357575d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions meshroom/ui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from meshroom.core.attribute import ListAttribute, Attribute
from meshroom.core.graph import Graph, GraphModification
from meshroom.core.node import Position
from meshroom.core.node import Position, CompatibilityIssue
from meshroom.core.nodeFactory import nodeFactory
from meshroom.core.typing import PathLike

Expand Down Expand Up @@ -439,15 +439,20 @@ def __init__(self, graph, node, parent=None):
super(UpgradeNodeCommand, self).__init__(graph, parent)
self.nodeDict = node.toDict()
self.nodeName = node.getName()
self.compatibilityIssue = None
self.setText("Upgrade Node {}".format(self.nodeName))

def redoImpl(self):
if not self.graph.node(self.nodeName).canUpgrade:
if not (node := self.graph.node(self.nodeName)).canUpgrade:
return False
self.compatibilityIssue = node.issue
return self.graph.upgradeNode(self.nodeName)

def undoImpl(self):
expectedUid = self.graph.node(self.nodeName)._uid
expectedUid = None
if self.compatibilityIssue == CompatibilityIssue.UidConflict:
expectedUid = self.graph.node(self.nodeName)._uid

# recreate compatibility node
with GraphModification(self.graph):
node = nodeFactory(self.nodeDict, name=self.nodeName, expectedUid=expectedUid)
Expand Down

0 comments on commit 357575d

Please sign in to comment.