Skip to content

Commit

Permalink
Fix CER crash on ConnectorViewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
reddyashish committed Feb 7, 2025
1 parent 7a076d8 commit a169f0c
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions src/DynamoCoreWpf/ViewModels/Core/ConnectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,16 +1222,20 @@ public override void Dispose()
{
NodeEnd.PropertyChanged -= nodeEndViewModel_PropertyChanged;
}
ConnectorPinViewCollection.CollectionChanged -= HandleCollectionChanged;

workspaceViewModel.PropertyChanged -= WorkspaceViewModel_PropertyChanged;

foreach (var pin in ConnectorPinViewCollection.ToList())
if (ConnectorPinViewCollection != null)
{
pin.RequestRedraw -= HandlerRedrawRequest;
pin.RequestSelect -= HandleRequestSelected;
ConnectorPinViewCollection.CollectionChanged -= HandleCollectionChanged;

foreach (var pin in ConnectorPinViewCollection.ToList())
{
pin.RequestRedraw -= HandlerRedrawRequest;
pin.RequestSelect -= HandleRequestSelected;
}
}

workspaceViewModel.PropertyChanged -= WorkspaceViewModel_PropertyChanged;

this.PropertyChanged -= ConnectorViewModelPropertyChanged;
DiscardAllConnectorPinModels();

Expand Down Expand Up @@ -1451,17 +1455,27 @@ internal List<Point> CollectPinLocations()
/// </summary>
public void Redraw()
{
if (this.ConnectorModel?.End != null && ConnectorPinViewCollection?.Count > 0)
try
{
RedrawBezierManyPoints();
if (this.ConnectorModel != null && ConnectorPinViewCollection != null)
{
if (this.ConnectorModel?.End != null && ConnectorPinViewCollection?.Count > 0)
{
RedrawBezierManyPoints();
}
else if (this.ConnectorModel?.End != null)
{
this.Redraw(this.ConnectorModel.End.Center);
}
}

this.SetCollapsedByNodeViewModel();
RaisePropertyChanged(nameof(ZIndex));
}
else if (this.ConnectorModel?.End != null)
catch (Exception ex)
{
this.Redraw(this.ConnectorModel.End.Center);
workspaceViewModel.DynamoViewModel.Model.Logger.Log("Error when redrawing the connector: " + ex.StackTrace);
}

this.SetCollapsedByNodeViewModel();
RaisePropertyChanged(nameof(ZIndex));
}

/// <summary>
Expand Down

0 comments on commit a169f0c

Please sign in to comment.