- std::map<std::string, std::set<int> >::iterator aFound = theExistingNames.find(aName);
- bool isUnique = false;
- if (aFound == theExistingNames.end())
- isUnique = true;
+ ObjectNameMap::iterator aFoundGroup = theExistingNames.find(aGroup);
+ bool isUnique = aFoundGroup == theExistingNames.end();
+
+ std::map<std::string, std::set<int> >::iterator aFound;
+ if (!isUnique) {
+ aFound = aFoundGroup->second.find(aName);
+ isUnique = aFound == aFoundGroup->second.end();
+ }
+
+ if (isUnique) {
+ // name is unique
+ aName = theObject->data()->name();
+ addIndexedName(theObject, theExistingNames);
+ }