invalid memory acces on pushStyle
in
Contributed Library Questions
•
1 year ago
I tried to isolate the problem in a small sketch but then there is no problem anymore.
Anyway, in the bigger sketch it always prints a (line 28) and then i get invalid memory acces so it never prints b (line 30).
However, if i remove pushStyle() and PopStyle() then the problem is gone.
Does anyone have a idea how this is possible?
- import controlP5.*;
- import javax.swing.JColorChooser;
- import java.awt.Color;
- ControlP5 cp5;
- color c = color(255, 255, 255);
- Color javaColor;
- void setup() {
- colorMode(HSB, 360, 100, 100, 100);
- gui();
- }
- void draw() {
- fill(c);
- ellipse(width/2, height/2, width/2, height/2);
- }
- void color1() {
- javaColor = JColorChooser.showDialog(this, "Java Color Chooser", Color.white);
- if (javaColor!=null) {
- pushStyle();
- colorMode(RGB, 255, 255, 255);
- c = color(javaColor.getRed(), javaColor.getGreen(), javaColor.getBlue());
- println("a");
- popStyle();
- println("b");
- }
- }
- void gui() {
- cp5 = new ControlP5(this);
- ControlWindow controlWindow;
- controlWindow = cp5.addControlWindow("controlP5window", 100, 100, 400, 600);
- cp5.addButton("color1")
- .setWindow(controlWindow)
- ;
- }
1