Skip to content

Commit

Permalink
ofParameterGroup: used escaped name to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
arturoc committed Jul 31, 2018
1 parent 079d057 commit 6f80d19
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
7 changes: 3 additions & 4 deletions libs/openFrameworks/types/ofParameterGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ void ofParameterGroup::remove(const string &name){
return;
}
size_t paramIndex = obj->parametersIndex[escaped];
auto it = obj->parameters.begin() + paramIndex;
obj->parameters.erase(it);
obj->parameters.erase(obj->parameters.begin() + paramIndex);
obj->parametersIndex.erase(escaped);
std::for_each(it, obj->parameters.end(), [&](shared_ptr<ofAbstractParameter>& p){
obj->parametersIndex[p->getName()] -= 1;
std::for_each(obj->parameters.begin() + paramIndex, obj->parameters.end(), [&](shared_ptr<ofAbstractParameter>& p){
obj->parametersIndex[p->getEscapedName()] -= 1;
});
}

Expand Down
26 changes: 13 additions & 13 deletions tests/types/parameters/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@

class ofApp: public ofxUnitTestsApp{
void run(){
ofParameter<float> p1{"p1", 0, 0, 1000};
ofParameter<float> p2{"p2", 0, 0, 1000};
ofParameter<float> p3{"p3", 0, 0, 1000};
ofParameter<float> p4{"p4", 0, 0, 1000};
ofParameter<float> p1{"p>1", 0, 0, 1000};
ofParameter<float> p2{"p>2", 0, 0, 1000};
ofParameter<float> p3{"p>3", 0, 0, 1000};
ofParameter<float> p4{"p>4", 0, 0, 1000};
ofParameterGroup group{
"group",
p1, p2, p3, p4
};
group.remove(p1);
ofxTest(!group.contains("p1"), "Group shouldn't contain p1 after remove");
ofxTestEq(group.get("p2").getName(), "p2", "p2 name should be p2, probably index map is corrupt"); //Issue #6016
ofxTestEq(group.get("p3").getName(), "p3", "p3 name should be p3, probably index map is corrupt"); //Issue #6016
ofxTestEq(group.get("p4").getName(), "p4", "p4 name should be p4, probably index map is corrupt"); //Issue #6016
ofxTest(!group.contains("p>1"), "Group shouldn't contain p1 after remove");
ofxTestEq(group.get("p>2").getName(), "p>2", "p2 name " + group.get("p>2").getName() + " should be p>2, probably index map is corrupt"); //Issue #6016
ofxTestEq(group.get("p>3").getName(), "p>3", "p3 name " + group.get("p>3").getName() + " should be p>3, probably index map is corrupt"); //Issue #6016
ofxTestEq(group.get("p>4").getName(), "p>4", "p4 name " + group.get("p>4").getName() + " should be p>4, probably index map is corrupt"); //Issue #6016
group.remove(p2);
ofxTest(!group.contains("p2"), "Group shouldn't contain p2 after remove");
ofxTestEq(group.get("p3").getName(), "p3", "p3 name should be p3, probably index map is corrupt"); //Issue #6016
ofxTestEq(group.get("p4").getName(), "p4", "p4 name should be p4, probably index map is corrupt"); //Issue #6016
ofxTest(!group.contains("p>2"), "Group shouldn't contain p2 after remove");
ofxTestEq(group.get("p>3").getName(), "p>3", "p3 name " + group.get("p>3").getName() + " should be p>3, probably index map is corrupt"); //Issue #6016
ofxTestEq(group.get("p>4").getName(), "p>4", "p4 name " + group.get("p>4").getName() + " should be p>4, probably index map is corrupt"); //Issue #6016
group.remove(p3);
ofxTest(!group.contains("p3"), "Group shouldn't contain p2 after remove");
ofxTestEq(group.get("p4").getName(), "p4", "p4 name " + group.get("p4").getName() + " should be p4, probably index map is corrupt"); //Issue #6016
ofxTest(!group.contains("p>3"), "Group shouldn't contain p2 after remove");
ofxTestEq(group.get("p>4").getName(), "p>4", "p4 name " + group.get("p>4").getName() + " should be p>4, probably index map is corrupt"); //Issue #6016
}
};

Expand Down

0 comments on commit 6f80d19

Please sign in to comment.