Skip to content

Commit

Permalink
DYN-7110 Fix crash when connecting nodes (#15340)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeusongit authored Jun 21, 2024
1 parent f893b7a commit bdf318a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/DynamoCoreWpf/ViewModels/Core/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,17 @@ internal void BeginConnection(Guid nodeId, int portIndex, PortType portType)
{
bool isInPort = portType == PortType.Input;

if (!(Model.GetModelInternal(nodeId) is NodeModel node)) return;
PortModel portModel = isInPort ? node.InPorts[portIndex] : node.OutPorts[portIndex];
if (Model.GetModelInternal(nodeId) is not NodeModel node) return;
PortModel portModel;
try
{
portModel = isInPort ? node.InPorts[portIndex] : node.OutPorts[portIndex];
}
catch(Exception ex)
{
this.DynamoViewModel.Model.Logger.Log("Failed to make connection: " + ex.Message);
return;
}

// Test if port already has a connection, if so grab it and begin connecting
// to somewhere else (we don't allow the grabbing of the start connector).
Expand All @@ -197,7 +206,7 @@ internal void BeginConnection(Guid nodeId, int portIndex, PortType portType)
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
this.DynamoViewModel.Model.Logger.Log(ex.Message);
}
}
}
Expand Down

0 comments on commit bdf318a

Please sign in to comment.