{"action":"created","comment":{"url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/comments/135600398","pull_request_review_id":59026481,"id":135600398,"diff_hunk":"@@ -192,6 +192,48 @@ void Component::finalizeFromProperties()\n \n     markPropertiesAsSubcomponents();\n     componentsFinalizeFromProperties();\n+\n+    auto subs = getImmediateSubcomponents();\n+    std::set<std::string> names{};\n+    std::string name{};\n+\n+    // increment the count of duplicates to use as a unique suffix\n+    int count{ 0 };\n+    // temp variable to hold the unique name used to rename a duplicate\n+    std::string uniqueName{};\n+\n+    for (auto& sub : subs) {\n+        name = sub->getName();\n+\n+        // reset duplicate count and search name\n+        count = 0;\n+        uniqueName = name;\n+\n+        // while the name is still not unique keep incrementing the count\n+        while (names.find(uniqueName) != names.cend()) {\n+            // In the future this should become an Exception \n+            //OPENSIM_THROW(SubcomponentsWithDuplicateName, getName(), searchName);\n+            // for now, rename the duplicately named subcomponent \n+            // but first test the uniqueness of the name (the while condition)\n+            uniqueName = name + \"_\" + std::to_string(count++);\n+        }\n+\n+        if (count > 0) { // if a duplicate\n+            // rename the the subcomponent with its verified unique name\n+            Component* mutableSub = const_cast<Component *>(sub.get());","path":"OpenSim/Common/Component.cpp","position":32,"original_position":32,"commit_id":"847a7486c4967b7391fca33bd93e48e716464ab0","original_commit_id":"847a7486c4967b7391fca33bd93e48e716464ab0","user":{"login":"chrisdembia","id":846001,"avatar_url":"https://avatars0.githubusercontent.com/u/846001?v=4","gravatar_id":"","url":"https://api.github.com/users/chrisdembia","html_url":"https://github.com/chrisdembia","followers_url":"https://api.github.com/users/chrisdembia/followers","following_url":"https://api.github.com/users/chrisdembia/following{/other_user}","gists_url":"https://api.github.com/users/chrisdembia/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisdembia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisdembia/subscriptions","organizations_url":"https://api.github.com/users/chrisdembia/orgs","repos_url":"https://api.github.com/users/chrisdembia/repos","events_url":"https://api.github.com/users/chrisdembia/events{/privacy}","received_events_url":"https://api.github.com/users/chrisdembia/received_events","type":"User","site_admin":false},"body":"Consider adding a `std::vector<SimTK::ReferencePtr<Component>> getImmediateSubcomponents() const;`","created_at":"2017-08-28T18:39:36Z","updated_at":"2017-08-28T18:45:12Z","html_url":"https://github.com/opensim-org/opensim-core/pull/1887#discussion_r135600398","pull_request_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/1887","_links":{"self":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/comments/135600398"},"html":{"href":"https://github.com/opensim-org/opensim-core/pull/1887#discussion_r135600398"},"pull_request":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/1887"}}},"pull_request":{"url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/1887","id":136555021,"html_url":"https://github.com/opensim-org/opensim-core/pull/1887","diff_url":"https://github.com/opensim-org/opensim-core/pull/1887.diff","patch_url":"https://github.com/opensim-org/opensim-core/pull/1887.patch","issue_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/1887","number":1887,"state":"open","locked":false,"title":"Ensure unique subcomponent names","user":{"login":"aseth1","id":6494122,"avatar_url":"https://avatars0.githubusercontent.com/u/6494122?v=4","gravatar_id":"","url":"https://api.github.com/users/aseth1","html_url":"https://github.com/aseth1","followers_url":"https://api.github.com/users/aseth1/followers","following_url":"https://api.github.com/users/aseth1/following{/other_user}","gists_url":"https://api.github.com/users/aseth1/gists{/gist_id}","starred_url":"https://api.github.com/users/aseth1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aseth1/subscriptions","organizations_url":"https://api.github.com/users/aseth1/orgs","repos_url":"https://api.github.com/users/aseth1/repos","events_url":"https://api.github.com/users/aseth1/events{/privacy}","received_events_url":"https://api.github.com/users/aseth1/received_events","type":"User","site_admin":false},"body":"Fixes issues #1768,  #1877, #1876 (pt 2.)  \r\nCurrently, a `Model` with subcomponents  that have duplicate (path) names loads fine and it is only when Model connections are being resolved that errors including run_time exceptions within Simbody are encountered. \r\n\r\n### Brief summary of changes\r\nIn this PR the problem of duplicate path names is addressed directly after `Model` loading/deserialization. `Component::finalizeFromProperties` now checks for duplicate named subcompomponents of the same type. If encountered a message is printed and it is renamed to be unique.\r\n\r\n### Testing I've completed\r\nAll tests pass. I also added an `SubcomponentsWithDuplicateName` exception and verified that duplicates were being flagged correctly before commenting out the exception and replacing it with a console message. I left the commented out lines and tests that throw because we should move to strict enforcement after a grace period of using 4.0 where models will be brought into compliance.\r\n\r\n### Looking for feedback on...\r\n\r\n### CHANGELOG.md (choose one)\r\n- updated \r\n\r\nThe Doxygen for this PR can be viewed at http://myosin.sourceforge.net/?C=N;O=D; click the folder whose name is this PR's number.\r\n","created_at":"2017-08-18T20:06:59Z","updated_at":"2017-08-28T18:45:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be12b6f3a8d2dce7ffdb14ba3a5066b1565d5a60","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/1887/commits","review_comments_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/1887/comments","review_comment_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/1887/comments","statuses_url":"https://api.github.com/repos/opensim-org/opensim-core/statuses/847a7486c4967b7391fca33bd93e48e716464ab0","head":{"label":"opensim-org:enforce_unique_subcomponent_names","ref":"enforce_unique_subcomponent_names","sha":"847a7486c4967b7391fca33bd93e48e716464ab0","user":{"login":"opensim-org","id":4370782,"avatar_url":"https://avatars0.githubusercontent.com/u/4370782?v=4","gravatar_id":"","url":"https://api.github.com/users/opensim-org","html_url":"https://github.com/opensim-org","followers_url":"https://api.github.com/users/opensim-org/followers","following_url":"https://api.github.com/users/opensim-org/following{/other_user}","gists_url":"https://api.github.com/users/opensim-org/gists{/gist_id}","starred_url":"https://api.github.com/users/opensim-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opensim-org/subscriptions","organizations_url":"https://api.github.com/users/opensim-org/orgs","repos_url":"https://api.github.com/users/opensim-org/repos","events_url":"https://api.github.com/users/opensim-org/events{/privacy}","received_events_url":"https://api.github.com/users/opensim-org/received_events","type":"Organization","site_admin":false},"repo":{"id":20775600,"name":"opensim-core","full_name":"opensim-org/opensim-core","owner":{"login":"opensim-org","id":4370782,"avatar_url":"https://avatars0.githubusercontent.com/u/4370782?v=4","gravatar_id":"","url":"https://api.github.com/users/opensim-org","html_url":"https://github.com/opensim-org","followers_url":"https://api.github.com/users/opensim-org/followers","following_url":"https://api.github.com/users/opensim-org/following{/other_user}","gists_url":"https://api.github.com/users/opensim-org/gists{/gist_id}","starred_url":"https://api.github.com/users/opensim-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opensim-org/subscriptions","organizations_url":"https://api.github.com/users/opensim-org/orgs","repos_url":"https://api.github.com/users/opensim-org/repos","events_url":"https://api.github.com/users/opensim-org/events{/privacy}","received_events_url":"https://api.github.com/users/opensim-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opensim-org/opensim-core","description":"SimTK OpenSim 4.0 C++ libraries and command-line applications, and Java/Python wrapping.","fork":false,"url":"https://api.github.com/repos/opensim-org/opensim-core","forks_url":"https://api.github.com/repos/opensim-org/opensim-core/forks","keys_url":"https://api.github.com/repos/opensim-org/opensim-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opensim-org/opensim-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opensim-org/opensim-core/teams","hooks_url":"https://api.github.com/repos/opensim-org/opensim-core/hooks","issue_events_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/events{/number}","events_url":"https://api.github.com/repos/opensim-org/opensim-core/events","assignees_url":"https://api.github.com/repos/opensim-org/opensim-core/assignees{/user}","branches_url":"https://api.github.com/repos/opensim-org/opensim-core/branches{/branch}","tags_url":"https://api.github.com/repos/opensim-org/opensim-core/tags","blobs_url":"https://api.github.com/repos/opensim-org/opensim-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opensim-org/opensim-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opensim-org/opensim-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/opensim-org/opensim-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opensim-org/opensim-core/statuses/{sha}","languages_url":"https://api.github.com/repos/opensim-org/opensim-core/languages","stargazers_url":"https://api.github.com/repos/opensim-org/opensim-core/stargazers","contributors_url":"https://api.github.com/repos/opensim-org/opensim-core/contributors","subscribers_url":"https://api.github.com/repos/opensim-org/opensim-core/subscribers","subscription_url":"https://api.github.com/repos/opensim-org/opensim-core/subscription","commits_url":"https://api.github.com/repos/opensim-org/opensim-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/opensim-org/opensim-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/opensim-org/opensim-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/opensim-org/opensim-core/contents/{+path}","compare_url":"https://api.github.com/repos/opensim-org/opensim-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opensim-org/opensim-core/merges","archive_url":"https://api.github.com/repos/opensim-org/opensim-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opensim-org/opensim-core/downloads","issues_url":"https://api.github.com/repos/opensim-org/opensim-core/issues{/number}","pulls_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls{/number}","milestones_url":"https://api.github.com/repos/opensim-org/opensim-core/milestones{/number}","notifications_url":"https://api.github.com/repos/opensim-org/opensim-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opensim-org/opensim-core/labels{/name}","releases_url":"https://api.github.com/repos/opensim-org/opensim-core/releases{/id}","deployments_url":"https://api.github.com/repos/opensim-org/opensim-core/deployments","created_at":"2014-06-12T16:57:56Z","updated_at":"2017-08-25T19:33:41Z","pushed_at":"2017-08-28T18:17:55Z","git_url":"git://github.com/opensim-org/opensim-core.git","ssh_url":"git@github.com:opensim-org/opensim-core.git","clone_url":"https://github.com/opensim-org/opensim-core.git","svn_url":"https://github.com/opensim-org/opensim-core","homepage":"https://opensim.stanford.edu","size":147687,"stargazers_count":82,"watchers_count":82,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":73,"mirror_url":null,"open_issues_count":400,"forks":73,"open_issues":400,"watchers":82,"default_branch":"master"}},"base":{"label":"opensim-org:master","ref":"master","sha":"4cb0385dd30faa25b5f49f95f6b6e7851f81338e","user":{"login":"opensim-org","id":4370782,"avatar_url":"https://avatars0.githubusercontent.com/u/4370782?v=4","gravatar_id":"","url":"https://api.github.com/users/opensim-org","html_url":"https://github.com/opensim-org","followers_url":"https://api.github.com/users/opensim-org/followers","following_url":"https://api.github.com/users/opensim-org/following{/other_user}","gists_url":"https://api.github.com/users/opensim-org/gists{/gist_id}","starred_url":"https://api.github.com/users/opensim-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opensim-org/subscriptions","organizations_url":"https://api.github.com/users/opensim-org/orgs","repos_url":"https://api.github.com/users/opensim-org/repos","events_url":"https://api.github.com/users/opensim-org/events{/privacy}","received_events_url":"https://api.github.com/users/opensim-org/received_events","type":"Organization","site_admin":false},"repo":{"id":20775600,"name":"opensim-core","full_name":"opensim-org/opensim-core","owner":{"login":"opensim-org","id":4370782,"avatar_url":"https://avatars0.githubusercontent.com/u/4370782?v=4","gravatar_id":"","url":"https://api.github.com/users/opensim-org","html_url":"https://github.com/opensim-org","followers_url":"https://api.github.com/users/opensim-org/followers","following_url":"https://api.github.com/users/opensim-org/following{/other_user}","gists_url":"https://api.github.com/users/opensim-org/gists{/gist_id}","starred_url":"https://api.github.com/users/opensim-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opensim-org/subscriptions","organizations_url":"https://api.github.com/users/opensim-org/orgs","repos_url":"https://api.github.com/users/opensim-org/repos","events_url":"https://api.github.com/users/opensim-org/events{/privacy}","received_events_url":"https://api.github.com/users/opensim-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opensim-org/opensim-core","description":"SimTK OpenSim 4.0 C++ libraries and command-line applications, and Java/Python wrapping.","fork":false,"url":"https://api.github.com/repos/opensim-org/opensim-core","forks_url":"https://api.github.com/repos/opensim-org/opensim-core/forks","keys_url":"https://api.github.com/repos/opensim-org/opensim-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opensim-org/opensim-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opensim-org/opensim-core/teams","hooks_url":"https://api.github.com/repos/opensim-org/opensim-core/hooks","issue_events_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/events{/number}","events_url":"https://api.github.com/repos/opensim-org/opensim-core/events","assignees_url":"https://api.github.com/repos/opensim-org/opensim-core/assignees{/user}","branches_url":"https://api.github.com/repos/opensim-org/opensim-core/branches{/branch}","tags_url":"https://api.github.com/repos/opensim-org/opensim-core/tags","blobs_url":"https://api.github.com/repos/opensim-org/opensim-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opensim-org/opensim-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opensim-org/opensim-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/opensim-org/opensim-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opensim-org/opensim-core/statuses/{sha}","languages_url":"https://api.github.com/repos/opensim-org/opensim-core/languages","stargazers_url":"https://api.github.com/repos/opensim-org/opensim-core/stargazers","contributors_url":"https://api.github.com/repos/opensim-org/opensim-core/contributors","subscribers_url":"https://api.github.com/repos/opensim-org/opensim-core/subscribers","subscription_url":"https://api.github.com/repos/opensim-org/opensim-core/subscription","commits_url":"https://api.github.com/repos/opensim-org/opensim-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/opensim-org/opensim-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/opensim-org/opensim-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/opensim-org/opensim-core/contents/{+path}","compare_url":"https://api.github.com/repos/opensim-org/opensim-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opensim-org/opensim-core/merges","archive_url":"https://api.github.com/repos/opensim-org/opensim-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opensim-org/opensim-core/downloads","issues_url":"https://api.github.com/repos/opensim-org/opensim-core/issues{/number}","pulls_url":"https://api.github.com/repos/opensim-org/opensim-core/pulls{/number}","milestones_url":"https://api.github.com/repos/opensim-org/opensim-core/milestones{/number}","notifications_url":"https://api.github.com/repos/opensim-org/opensim-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opensim-org/opensim-core/labels{/name}","releases_url":"https://api.github.com/repos/opensim-org/opensim-core/releases{/id}","deployments_url":"https://api.github.com/repos/opensim-org/opensim-core/deployments","created_at":"2014-06-12T16:57:56Z","updated_at":"2017-08-25T19:33:41Z","pushed_at":"2017-08-28T18:17:55Z","git_url":"git://github.com/opensim-org/opensim-core.git","ssh_url":"git@github.com:opensim-org/opensim-core.git","clone_url":"https://github.com/opensim-org/opensim-core.git","svn_url":"https://github.com/opensim-org/opensim-core","homepage":"https://opensim.stanford.edu","size":147687,"stargazers_count":82,"watchers_count":82,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":73,"mirror_url":null,"open_issues_count":400,"forks":73,"open_issues":400,"watchers":82,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/1887"},"html":{"href":"https://github.com/opensim-org/opensim-core/pull/1887"},"issue":{"href":"https://api.github.com/repos/opensim-org/opensim-core/issues/1887"},"comments":{"href":"https://api.github.com/repos/opensim-org/opensim-core/issues/1887/comments"},"review_comments":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/1887/comments"},"review_comment":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opensim-org/opensim-core/pulls/1887/commits"},"statuses":{"href":"https://api.github.com/repos/opensim-org/opensim-core/statuses/847a7486c4967b7391fca33bd93e48e716464ab0"}}}}
{"actor":{"display_login":"chrisdembia"}}