diff --git a/tesseract_task_composer/core/src/task_composer_node_info.cpp b/tesseract_task_composer/core/src/task_composer_node_info.cpp index 72953de1fc..fc2c853a89 100644 --- a/tesseract_task_composer/core/src/task_composer_node_info.cpp +++ b/tesseract_task_composer/core/src/task_composer_node_info.cpp @@ -103,7 +103,9 @@ TaskComposerNodeInfoContainer::TaskComposerNodeInfoContainer(const TaskComposerN std::shared_lock rhs_lock(other.mutex_, std::defer_lock); std::scoped_lock lock{ lhs_lock, rhs_lock }; - *this = other; + aborting_node_ = other.aborting_node_; + for (const auto& pair : other.info_map_) + info_map_[pair.first] = pair.second->clone(); } TaskComposerNodeInfoContainer& TaskComposerNodeInfoContainer::operator=(const TaskComposerNodeInfoContainer& other) { @@ -111,6 +113,7 @@ TaskComposerNodeInfoContainer& TaskComposerNodeInfoContainer::operator=(const Ta std::shared_lock rhs_lock(other.mutex_, std::defer_lock); std::scoped_lock lock{ lhs_lock, rhs_lock }; + aborting_node_ = other.aborting_node_; for (const auto& pair : other.info_map_) info_map_[pair.first] = pair.second->clone(); @@ -123,7 +126,8 @@ TaskComposerNodeInfoContainer::TaskComposerNodeInfoContainer(TaskComposerNodeInf std::unique_lock rhs_lock(other.mutex_, std::defer_lock); std::scoped_lock lock{ lhs_lock, rhs_lock }; - *this = std::move(other); + aborting_node_ = other.aborting_node_; + info_map_ = std::move(other.info_map_); } TaskComposerNodeInfoContainer& TaskComposerNodeInfoContainer::operator=(TaskComposerNodeInfoContainer&& other) noexcept { @@ -131,6 +135,7 @@ TaskComposerNodeInfoContainer& TaskComposerNodeInfoContainer::operator=(TaskComp std::unique_lock rhs_lock(other.mutex_, std::defer_lock); std::scoped_lock lock{ lhs_lock, rhs_lock }; + aborting_node_ = other.aborting_node_; info_map_ = std::move(other.info_map_); return *this; @@ -252,6 +257,7 @@ template void TaskComposerNodeInfoContainer::serialize(Archive& ar, const unsigned int /*version*/) { std::unique_lock lock(mutex_); + ar& BOOST_SERIALIZATION_NVP(aborting_node_); ar& BOOST_SERIALIZATION_NVP(info_map_); } diff --git a/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp b/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp index 067d9a36c6..d97fe26761 100644 --- a/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp +++ b/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp @@ -168,10 +168,14 @@ TEST(TesseractTaskComposerCoreUnit, TaskComposerNodeInfoContainerTests) // NOLI auto node_info = std::make_unique(node); auto node_info_container = std::make_unique(); + EXPECT_TRUE(node_info_container->getAbortingNode().is_nil()); EXPECT_TRUE(node_info_container->getInfoMap().empty()); + auto aborted_uuid = node.getUUID(); node_info_container->addInfo(std::move(node_info)); + node_info_container->setAborted(aborted_uuid); EXPECT_EQ(node_info_container->getInfoMap().size(), 1); EXPECT_TRUE(node_info_container->getInfo(node.getUUID()) != nullptr); + EXPECT_TRUE(node_info_container->getAbortingNode() == aborted_uuid); // Serialization test_suite::runSerializationPointerTest(node_info_container, "TaskComposerNodeInfoContainerTests"); @@ -180,15 +184,18 @@ TEST(TesseractTaskComposerCoreUnit, TaskComposerNodeInfoContainerTests) // NOLI auto copy_node_info_container = std::make_unique(*node_info_container); EXPECT_EQ(copy_node_info_container->getInfoMap().size(), 1); EXPECT_TRUE(copy_node_info_container->getInfo(node.getUUID()) != nullptr); + EXPECT_TRUE(copy_node_info_container->getAbortingNode() == aborted_uuid); // Move auto move_node_info_container = std::make_unique(std::move(*node_info_container)); EXPECT_EQ(move_node_info_container->getInfoMap().size(), 1); EXPECT_TRUE(move_node_info_container->getInfo(node.getUUID()) != nullptr); + EXPECT_TRUE(move_node_info_container->getAbortingNode() == aborted_uuid); move_node_info_container->clear(); EXPECT_TRUE(move_node_info_container->getInfoMap().empty()); EXPECT_TRUE(move_node_info_container->getInfo(node.getUUID()) == nullptr); + EXPECT_TRUE(move_node_info_container->getAbortingNode().is_nil()); } TEST(TesseractTaskComposerCoreUnit, TaskComposerNodeTests) // NOLINT