The problem:
You add three buttons to a controller. Then try and remove them in the order
they were added.
You get an exception thrown. If you remove the buttons in the opposite order
that they were
added, it works fine.
To reproduce:
c = new GUIController(this);
b1 = new IFButton("Button1", 10, 10);
b2 = new IFButton("Button2", 10, 40);
b3 = new IFButton("Button3", 10, 70);
c.add(b1);
c.add(b2);
c.add(b3);
c.remove(b1);
/*Exception thrown */
The cause:
Line 110 of GUIController.java is currently:
System.arraycopy(contents, componentIndex + 1, contents, componentIndex,
numItems);
However, that will always fail, as numItems is always larger than the segment
we are trying to
copy (it can be at most numItems - 1 items long). This causes an
IndexOutOfBoundsException.
The solution:
Line 110 of GUIController.java should be:
System.arraycopy(contents, componentIndex + 1, contents, componentIndex,
numItems -
(componentIndex + 1));
The length of the array segment to copy is numItems - (componentIndex + 1)
instead of
numItems.
All line numbers and file names are from SVN revision 26.
Original issue reported on code.google.com by hole...@gmail.com on 22 Aug 2007 at 4:48
Original issue reported on code.google.com by
hole...@gmail.com
on 22 Aug 2007 at 4:48