Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListBox, index out of bound #124

Open
frankiezafe opened this issue Jun 11, 2018 · 1 comment
Open

ListBox, index out of bound #124

frankiezafe opened this issue Jun 11, 2018 · 1 comment

Comments

@frankiezafe
Copy link

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.

@orgicus
Copy link

orgicus commented Jul 31, 2018

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants