You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was a regression introduced between LGM 16b4 and 1.8.2
I can confirm that this was not my doing because I checked out 4fa0748 and still had the issue. The reason this is not my fault is because this revision was before I ever contributed to LGM. So it was introduced in the interim between this revision and whatever revision 16b4 was.
To reproduce in every release since 16b4 do the following:
Open LGM
Create a new path
Slowly create a new point anywhere about every 5 seconds apart, observe that nothing wrong occurs.
Now more rapidly create the points as quickly as possible and notice that multiple path points will be selected, there will be multiple red points where there should only be 1 and the rest should be blue.
Right click on one of the selected/red path points to delete it and observe the NPE
The issue does not occur with 44d0ae4 but does occur with 22c2e6e
The problem is essentially that PathPoint is used in a HashMap and HashSet in PathEditor as the key for the related PointVisual. PathPoint is a mutable object whose x, y, and speed can be changed. This is why using a custom hashCode() and equals() based on the property map does not work, especially because the point can be moved directly after being created (which it does if CTRL is not pressed).
This was a regression introduced between LGM 16b4 and 1.8.2
I can confirm that this was not my doing because I checked out 4fa0748 and still had the issue. The reason this is not my fault is because this revision was before I ever contributed to LGM. So it was introduced in the interim between this revision and whatever revision 16b4 was.
To reproduce in every release since 16b4 do the following:
The issue does not occur with 44d0ae4 but does occur with 22c2e6e
Further investigation of 22c2e6e indicates that removing the added override (22c2e6e#diff-fba598e1b486734a688bd38bd4ec6bb6R84) to hashCode() fixes the issue in the latest LateralGM
The problem is essentially that PathPoint is used in a HashMap and HashSet in PathEditor as the key for the related PointVisual. PathPoint is a mutable object whose x, y, and speed can be changed. This is why using a custom hashCode() and equals() based on the property map does not work, especially because the point can be moved directly after being created (which it does if CTRL is not pressed).
So the solution from the following Stack Overflow post will be used to address the issue, I will be replacing the use of HashMap in PathEditor with IdentityHashMap for the next LGM release. This both addresses the immediate issue with the path frame and reverting unsaved changes continues to work as normal.
http://stackoverflow.com/questions/5797373/java-map-based-on-object-reference
https://docs.oracle.com/javase/7/docs/api/java/util/IdentityHashMap.html
LateralGM/org/lateralgm/components/visual/PathEditor.java
Line 85 in 4276803
The text was updated successfully, but these errors were encountered: