-
Notifications
You must be signed in to change notification settings - Fork 635
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
DYN-2286: fix for crash upon unresolved node undo #10315
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ public enum PortType { Input, Output }; | |
/// <summary> | ||
/// PortModel represents Dynamo ports. | ||
/// </summary> | ||
public class PortModel : ModelBase | ||
public class PortModel : ModelBase, IEquatable<PortModel> | ||
{ | ||
#region private fields | ||
ObservableCollection<ConnectorModel> connectors = new ObservableCollection<ConnectorModel>(); | ||
|
@@ -369,6 +369,23 @@ protected override void DeserializeCore(XmlElement nodeElement, SaveContext cont | |
} | ||
|
||
#endregion | ||
|
||
public bool Equals(PortModel other) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. last time I tried overriding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, I'm checking for guid equality only if reference equality fails. From what I see in other nodemodel types, it looks like the equality check will either be true or false in both cases (reference equality + guid equality) since if the same port model is being reused, both conditions will be true, and if a new port model is created, still both conditions will be false, unless the new ports are created using the same guids as the old ones, which is what I'm enforcing here explicitly for dummy nodes. |
||
{ | ||
if (other == null) return false; | ||
|
||
if (this == other) return true; | ||
|
||
if (GUID == other.GUID) return true; | ||
|
||
return false; | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return GUID.GetHashCode(); | ||
} | ||
|
||
} | ||
|
||
/// <summary> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if childNodes is null - this will throw an exception - I think you should keep the if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://stackoverflow.com/questions/3088147/why-does-net-foreach-loop-throw-nullrefexception-when-collection-is-null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resharper tells me that expression will always be true.