Skip to content

Commit

Permalink
ofParameterGroup: fix some issues with parameter removal
Browse files Browse the repository at this point in the history
Fixes #6016
  • Loading branch information
arturoc committed Jul 30, 2018
1 parent 1afcb3b commit bad923d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions libs/openFrameworks/types/ofParameterGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ void ofParameterGroup::add(ofAbstractParameter & parameter){
}

void ofParameterGroup::remove(ofAbstractParameter &param){
std::for_each(obj->parameters.begin(), obj->parameters.end(), [&](shared_ptr<ofAbstractParameter>& p){
// std::for_each(obj->parameters.begin(), obj->parameters.end(), [&](shared_ptr<ofAbstractParameter>& p){
for(auto & p: obj->parameters){
cout << p->getName() << endl;
if(p->isReferenceTo(param)){
remove(param.getName());
return;
}
});
}
}

void ofParameterGroup::remove(size_t index){
Expand All @@ -39,8 +42,12 @@ void ofParameterGroup::remove(const string &name){
if(!contains(name)){
return;
}
obj->parameters.erase(obj->parameters.begin() + obj->parametersIndex[name]);
size_t paramIndex = obj->parametersIndex[name];
obj->parameters.erase(obj->parameters.begin() + paramIndex);
obj->parametersIndex.erase(name);
std::for_each(obj->parameters.begin() + paramIndex, obj->parameters.end(), [&](shared_ptr<ofAbstractParameter>& p){
obj->parametersIndex[p->getName()] -= 1;
});
}

void ofParameterGroup::clear(){
Expand Down

0 comments on commit bad923d

Please sign in to comment.