-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Hi everyone.
Playing with ofParameterGroups I found an issue with ofParameterGroup::contains(...)
openFrameworks/libs/openFrameworks/types/ofParameterGroup.cpp
Lines 422 to 424 in 5453d35
| bool ofParameterGroup::contains(const string& name) const{ | |
| return obj->parametersIndex.find(escape(name))!=obj->parametersIndex.end(); | |
| } |
std::map<std::string,std::size_t> parametersIndex; is used.
The issue pops up when you change the name of a parameter that is already inside the parameterGroup. The name changes of the parameter changes, but the name in parametersIndex does, not and so we cannot find our parameter inside the parameterGroup. Because the parameterIndex map is only created when adding parameters, and only modified when removing, the only workaround for this is to remove the element from the group, changing the name, and adding it again. With that changing the order of the elements in the group.
As ofParameter has a public method of ::setName(), this case should be considered right?
As there is no event fired by the ofParameter when the name is changed, I think the best solution is to get rid of parametersIndex and search the parameters vector directly so we get the updated name every time we make the request.
Eduard