braitsch / ofxDatGui

Simple to use, fully customizable, high-resolution graphical user interface for openFrameworks

Home Page:https://braitsch.github.io/ofxDatGui/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delete doesn't work with color picker in a folder

janrope opened this issue · comments

The destructor of ofxDatGui causes a "Access violation reading location" error if it contains an ofxDatGuiFolder which itself contains an ofxDatGuiColorPicker.

The exception is thrown at ~ofxDatGuiGroup().

Add the following code for a MWE:

ofApp.h

#include "ofMain.h"
#include "ofxDatGui.h"

class ofApp : public ofBaseApp{

public:
void setup();
void update();
ofxDatGui* gui;
};

ofApp.ccp

#include "ofApp.h"

void ofApp::setup(){
gui = new ofxDatGui(ofxDatGuiAnchor::TOP_LEFT);
ofxDatGuiFolder* ofFolder = gui->addFolder("Draw options", ofColor::orangeRed);
ofFolder->addColorPicker("- Cross color", ofColor::gray);
}

void ofApp::update(){
delete gui;
}

Calling delete in your update loop calls delete multiple times so essentially you're trying to delete something that doesn't exist after the first time it is deleted, hence the error. Calling delete on say a keypress or mouse click will delete the GUI once instead of trying to delete it over and over again.

void ofApp::keyPressed(int key){
    if (key == 'd') delete gui;
}