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

Path Editor Reference Equality #231

RobertBColton opened this Issue Nov 19, 2015 · 0 comments


None yet
1 participant

RobertBColton commented Nov 19, 2015

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:

  1. Open LGM
  2. Create a new path
  3. Slowly create a new point anywhere about every 5 seconds apart, observe that nothing wrong occurs.
  4. 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.
  5. 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

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.

private final HashMap<PathPoint,PointVisual> pvMap;

@RobertBColton RobertBColton changed the title from Path Editor Selected Item to Path Editor Selected Point Nov 19, 2015

@RobertBColton RobertBColton changed the title from Path Editor Selected Point to Path Editor Reference Equality and Depth Ordering Nov 24, 2015

@RobertBColton RobertBColton changed the title from Path Editor Reference Equality and Depth Ordering to Path Editor Reference Equality Nov 26, 2015

This was referenced Jan 23, 2016

@RobertBColton RobertBColton closed this in #245 Feb 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment