Changeset 33133 in osm for applications


Ignore:
Timestamp:
2017-01-30T23:41:59+01:00 (8 years ago)
Author:
donvip
Message:

fix #josm11923, fix #josm12132, fix #josm14315 - AlignWays: way highlights are not cleaned up (patch by IdealChain)

Location:
applications/editors/josm/plugins/alignways
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/alignways/build.xml

    r32680 r33133  
    1414    <property name="plugin.icon" value="images/alignways.png"/>
    1515    <property name="plugin.link" value="https://wiki.openstreetmap.org/wiki/JOSM/Plugins/AlignWayS"/>
     16    <property name="plugin.canloadatruntime" value="true"/>
    1617
    1718    <!-- ** include targets that all plugins have in common ** -->
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysSegment.java

    r32921 r33133  
    1313import java.util.Collection;
    1414import java.util.HashSet;
     15import java.util.Objects;
    1516
    1617import org.openstreetmap.josm.Main;
     
    114115     @Override
    115116     public int hashCode() {
    116         final int prime = 31;
    117         int result = 1;
    118         result = prime * result + ((segment == null) ? 0 : segment.hashCode());
    119         result = prime * result
    120                 + ((segmentColor == null) ? 0 : segmentColor.hashCode());
    121         return result;
     117        if (segment == null) {
     118            return System.identityHashCode(this);
     119        }
     120
     121        // hashCode and equals should be consistent during the lifetime of this segment,
     122        // otherwise the temporary mapview overlay will not be properly removed on destroy()
     123        return segment.hashCode();
    122124     }
    123125
    124      @Override
    125      public boolean equals(Object obj) {
    126          if (this == obj)
    127              return true;
    128          if (obj == null)
    129              return false;
    130          if (!(obj instanceof AlignWaysSegment))
    131              return false;
    132          AlignWaysSegment other = (AlignWaysSegment) obj;
    133          if (segment == null) {
    134              if (other.segment != null)
    135                  return false;
    136          } else if (!segment.equals(other.segment))
    137              return false;
    138          /* Segment colour is ignored in comparison
    139         if (segmentColor == null) {
    140             if (other.segmentColor != null)
    141                 return false;
    142         } else if (!segmentColor.equals(other.segmentColor))
    143             return false;
    144           */
    145          return true;
    146      }
     126    @Override
     127    public boolean equals(Object o) {
     128        if (this == o) return true;
     129        if (!(o instanceof AlignWaysSegment)) return false;
     130        AlignWaysSegment that = (AlignWaysSegment) o;
     131        return Objects.equals(segment, that.segment);
     132    }
     133
    147134}
Note: See TracChangeset for help on using the changeset viewer.