diff --git a/dart/common/detail/NameManager.h b/dart/common/detail/NameManager.h index 164b274bdd4be..224f2d0fe6ad7 100644 --- a/dart/common/detail/NameManager.h +++ b/dart/common/detail/NameManager.h @@ -200,7 +200,7 @@ template void NameManager::removeEntries(const std::string& _name, const T& _obj) { removeObject(_obj); - removeName(_name, false); + removeName(_name); } //============================================================================== diff --git a/unittests/testNameManagement.cpp b/unittests/testNameManagement.cpp index f0b4c6181ba29..774acb745c0a4 100644 --- a/unittests/testNameManagement.cpp +++ b/unittests/testNameManagement.cpp @@ -216,6 +216,36 @@ TEST(NameManagement, SetPattern) EXPECT_TRUE( test_mgr.getObject("(2)-Entity") == entity2 ); } +//============================================================================== +TEST(NameManagement, Regression554) +{ + dart::common::NameManager< std::shared_ptr > test_mgr("test", "name"); + + std::shared_ptr int0(new int(0)); + std::shared_ptr int1(new int(1)); + std::shared_ptr int2(new int(2)); + std::shared_ptr int_another0(new int(0)); + + test_mgr.issueNewNameAndAdd(std::to_string(*int0), int0); + test_mgr.issueNewNameAndAdd(std::to_string(*int1), int1); + test_mgr.issueNewNameAndAdd(std::to_string(*int2), int2); + + EXPECT_TRUE( test_mgr.getObject("0") == int0 ); + EXPECT_TRUE( test_mgr.getObject("1") == int1 ); + EXPECT_TRUE( test_mgr.getObject("2") == int2 ); + + bool res1 = test_mgr.addName(std::to_string(*int_another0), int_another0); + EXPECT_FALSE( res1 ); + + test_mgr.removeEntries(std::to_string(*int_another0), int_another0); + bool res2 = test_mgr.addName(std::to_string(*int_another0), int_another0); + EXPECT_TRUE( res2 ); + + EXPECT_TRUE( test_mgr.getObject("0") == int_another0 ); + EXPECT_TRUE( test_mgr.getObject("1") == int1 ); + EXPECT_TRUE( test_mgr.getObject("2") == int2 ); +} + //============================================================================== TEST(NameManagement, WorldSkeletons) {