[cp-patches] FYI: Don't close a GeneralPath twice

Mark Wielaard mark at klomp.org
Thu Jun 15 18:17:36 UTC 2006


Hi,

Some code seems to close a GeneralPath twice which adds extra SEG_CLOSEs
at the end of a path. This caused some trouble in other code which
wasn't expecting to see multiple SEG_CLOSEs at the end. Other
documentation also implies that if a GeneralPath is closed it just stays
closed when closePath() is called again.

2006-06-15  Mark Wielaard  <mark at klomp.org>

    * java/awt/geom/GeneralPath.java (closePath): Return if path already
    closed.

Committed,

Mark

diff -u -r1.15 GeneralPath.java
--- java/awt/geom/GeneralPath.java      11 May 2006 08:27:27 -0000      1.15
+++ java/awt/geom/GeneralPath.java      15 Jun 2006 18:13:37 -0000
@@ -247,10 +247,12 @@

   /**
    * Closes the current subpath by drawing a line
-   * back to the point of the last moveTo.
+   * back to the point of the last moveTo, unless the path is already closed.
    */
   public void closePath()
   {
+    if (index >= 1 && types[index - 1] == PathIterator.SEG_CLOSE)
+      return;
     ensureSize(index + 1);
     types[index] = PathIterator.SEG_CLOSE;
     xpoints[index] = xpoints[subpath];

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://developer.classpath.org/pipermail/classpath-patches/attachments/20060615/01e8ecd9/attachment.pgp


More information about the Classpath-patches mailing list