Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not set execution hint on undo move #11519

Merged
merged 2 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/DynamoCore/Graph/Nodes/NodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ protected override void DeserializeCore(XmlElement nodeElement, SaveContext cont
argumentLacing = helper.ReadEnum("lacing", LacingStrategy.Disabled);
IsSetAsInput = helper.ReadBoolean("isSelectedInput", false);
IsSetAsOutput = helper.ReadBoolean("isSelectedOutput", false);
isFrozenExplicitly = helper.ReadBoolean("IsFrozen", false);
IsFrozen = helper.ReadBoolean("IsFrozen", false);
PreviewPinned = helper.ReadBoolean("isPinned", false);

var portInfoProcessed = new HashSet<int>();
Expand Down Expand Up @@ -2306,13 +2306,6 @@ var port in
RaisePropertyChanged(nameof(ArgumentLacing));
RaisePropertyChanged(nameof(IsVisible));
RaisePropertyChanged(nameof(DisplayLabels));
RaisePropertyChanged(nameof(IsSetAsInput));
RaisePropertyChanged(nameof(IsSetAsOutput));
//we need to modify the downstream nodes manually in case the
//undo is for toggling freeze. This is ONLY modifying the execution hint.
// this does not run the graph.
RaisePropertyChanged(nameof(IsFrozen));
MarkDownStreamNodesAsModified(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mmisol Did you test that downstream node can be also reverted back to the previous state?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow. Could you mention the steps of the test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, if a node is frozen, the downstream nodes are also frozen. The original code seems taking care of correctly marking downstream nodes when undo freezing node as well. Just want to make sure the behavior is the same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok. Yes, I tested that and it works


// Notify listeners that the position of the node has changed,
// then all connected connectors will also redraw themselves.
Expand Down
9 changes: 6 additions & 3 deletions src/DynamoCore/Graph/Nodes/PortModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,12 @@ public bool UsingDefaultValue
get { return usingDefaultValue; }
set
{
usingDefaultValue = value;
RaisePropertyChanged("UsingDefaultValue");
RaisePropertyChanged("ToolTip");
if (usingDefaultValue != value)
{
usingDefaultValue = value;
RaisePropertyChanged("UsingDefaultValue");
RaisePropertyChanged("ToolTip");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the fix here. Also curious does similar problem not exist for other properties, e.g. X, Y etc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this pattern is used in most places. For X and Y, I noticed they are deprecated and there is a Position which is a way to update both. Maybe that's the reason why it's different.

}
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/Libraries/PythonNodeModels/PythonNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,14 @@ protected override void DeserializeCore(XmlElement nodeElement, SaveContext cont

if (engineNode != null)
{
this.Engine = (PythonEngineVersion)Enum.Parse(typeof(PythonEngineVersion),engineNode.InnerText);
var oldEngine = Engine;
Engine = (PythonEngineVersion)Enum.Parse(typeof(PythonEngineVersion), engineNode.InnerText);
if (context == SaveContext.Undo && oldEngine != this.Engine)
{
// For Python nodes, changing the Engine property does not set the node Modified flag.
// This is done externally in all event handlers, so for Undo we do it here.
OnNodeModified();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

}
}
}

Expand Down
23 changes: 23 additions & 0 deletions test/DynamoCoreTests/CoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,29 @@ public void PasteInputAndOutputNodeInHomeWorkspace()
Assert.IsInstanceOf<CodeBlockNodeModel>(homeNodes.ElementAt(1));
}

[Test]
public void UndoMoveDoesNotForceExecution()
{
string openPath = Path.Combine(TestDirectory, @"core\LacingTest.dyn");
OpenModel(openPath);
RunCurrentModel();

var sumNodeGuid = new Guid("088365b5-4543-4e73-9430-463475147e19");
var sumNode = CurrentDynamoModel.CurrentWorkspace.Nodes.First(node => node.GUID == sumNodeGuid);
Assert.IsFalse(sumNode.IsModified);

var oldX = sumNode.X;
var newX = sumNode.X + 100;
var newPosition = $"{newX};{sumNode.Y}";
CurrentDynamoModel.ExecuteCommand(new DynCmd.UpdateModelValueCommand(Guid.Empty, sumNodeGuid, nameof(NodeModel.Position), newPosition));
Assert.AreEqual(newX, sumNode.X);

CurrentDynamoModel.ExecuteCommand(new DynCmd.UndoRedoCommand(DynCmd.UndoRedoCommand.Operation.Undo));
Assert.AreEqual(oldX, sumNode.X);

Assert.IsFalse(sumNode.IsModified);
}

[Test]
public void TestFileDirtyOnLacingChange()
{
Expand Down