Open frankiezafe opened 6 years ago
@sojamo I have bumped into the same issue. It is as if the onRelease() event tries to find a list item that isn't there and goes out of bounds.
Here's a minimal sketch to reproduce the bug:
import controlP5.*;
ControlP5 gui;
ListBox list;
void setup(){
gui = new ControlP5(this);
list = gui.addListBox("list")
.addItem("Item #1",0)
.addItem("Item #2",1)
.addItem("Item #3",2);
}
void draw(){
background(0);
text("click here\nto crash",10,60);
}
Clicking bellow the list will cause the crash:
ControlP5 2.2.6 infos, comments, questions at http://www.sojamo.de/libraries/controlP5
java.lang.IndexOutOfBoundsException: Index: 4, Size: 3
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at controlP5.ListBox.onRelease(Unknown Source)
at controlP5.Controller.setMousePressed(Unknown Source)
at controlP5.ControllerGroup.setMousePressed(Unknown Source)
at controlP5.ControlWindow.mouseReleasedEvent(Unknown Source)
at controlP5.ControlWindow.mouseEvent(Unknown Source)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1408)
at processing.core.PApplet.handleMethods(PApplet.java:1603)
at processing.core.PApplet.handleMouseEvent(PApplet.java:2695)
at processing.core.PApplet.dequeueEvents(PApplet.java:2618)
at processing.core.PApplet.handleDraw(PApplet.java:2429)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1540)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
The index increases as you click lower.
This is with ControlP5 2.2.6 on Processing 3.2.3 on OSX 10.11.6
Update: Thanks @frankiezafe , just spotted your listbox quick fix pull request, applied it and recompiled the library.
Hello, I have a crash triggered by ListBox::onRelease() method - it seems that the computation of index is wrong in some case. My usage is a bit specific, as I use the LuistBox in a sub-sketch where the draw method is triggered by the main sketch.
Here is the error:
java.lang.IndexOutOfBoundsException: Index: 7, Size: 2 at java.util.ArrayList.rangeCheck(ArrayList.java:653) at java.util.ArrayList.get(ArrayList.java:429) at controlP5.ListBox.onRelease(Unknown Source)
All the best.