codenameone

Has anyone encountered an Index Out Of Bounds error working with Drag and DropTarget Grids?


I am using Drag and Drop to move characters around the screen, recording the location on the screen, then running the movement of the characters showing the characters moving to each grid location. This screen has functioned properly for over a year and a half. In the final testing, I created blank copies of the storage databases, Started the app fresh to write the databases to simulator memory, and ran the MoveByDrag class fresh. When I move the first object, I now get a the following error:

[EDT] 0:0:29,715 - Exception: java.lang.ArrayIndexOutOfBoundsException - Index 0 out of bounds for length 0

The Stacktrace shows:

Index 0 out of bounds for length 0

The first line of the Failure Path is:

at com.codename1.ui.Container$MorphAnimation.updateState(Container.java:4335)

Which points to the last line in this section:

        @Override
        protected void updateState() {
            if(animatedComponents != null) {
                int componentCount = animatedComponents.size();
                for(int iter = 0 ; iter < componentCount ; iter++) {
                    Component currentCmp = (Component)animatedComponents.elementAt(iter);

                    currentCmp.setX(motions[0][iter].getValue());
                    currentCmp.setY(motions[1][iter].getValue());
                    currentCmp.setWidth(motions[2][iter].getValue());
                    currentCmp.setHeight(motions[3][iter].getValue());

The first character moved of the 24 characters locks the Simulator, which must be Force Quit. Has anyone encountered and overcome this issue?

Edit 1 Intellij identified setHeight as the first link in the error.


Solution

  • It seems this is a bug I introduced to the code in 7.0.208. I'm working on a fix which should be available this weekend (with 7.0.210). In the meantime for the simulator (albeit not the build server) you can work around it by editing the pom.xml and replacing the version from LATEST to 7.0.207.

    Don't forget to refresh maven after editing the pom.