Ticket #22317: Fix_FastDraw_crash_when_removing_the_last_point_of_a_polygon.patch

File Fix_FastDraw_crash_when_removing_the_last_point_of_a_polygon.patch, 1016 bytes (added by TrickyFoxy, 3 years ago)

fix FastDraw crash

  • src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java

    Subject: [PATCH] Fix FastDraw crash when removing the last point of a polygon
    ---
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java b/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java
    a b  
    239239    }
    240240
    241241    void deleteNode(int idx) {
    242         if (idx <= lastIdx) lastIdx--;
     242        if (isClosed()){
     243            if (idx == 0) idx = getPointCount() - 1;
     244            if (idx == getPointCount() - 1) closedFlag = false;
     245        }
     246        if (idx <= lastIdx && lastIdx != 0) lastIdx--;
    243247        fixed.remove(points.get(idx));
    244248        points.remove(idx);
    245249    }