From 27f76d69e530bbdf07030f2bb61c2f680f0712e5 Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Mon, 16 Oct 2017 18:07:38 +0200
Subject: [PATCH] Fix loop of shared ptr of SymbolicComponent

---
 include/hpp/manipulation/symbolic-component.hh |  2 +-
 src/symbolic-component.cc                      | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/hpp/manipulation/symbolic-component.hh b/include/hpp/manipulation/symbolic-component.hh
index da122d51..0648b081 100644
--- a/include/hpp/manipulation/symbolic-component.hh
+++ b/include/hpp/manipulation/symbolic-component.hh
@@ -34,7 +34,7 @@ namespace hpp {
     class HPP_MANIPULATION_DLLAPI SymbolicComponent
     {
       public:
-        typedef std::set<SymbolicComponentPtr_t> SymbolicComponents_t;
+        typedef std::set<SymbolicComponent*> SymbolicComponents_t;
 
         /// return a shared pointer to new instance
         static SymbolicComponentPtr_t create (const RoadmapPtr_t& roadmap);
diff --git a/src/symbolic-component.cc b/src/symbolic-component.cc
index 8de3e738..3eb5ed20 100644
--- a/src/symbolic-component.cc
+++ b/src/symbolic-component.cc
@@ -52,18 +52,18 @@ namespace hpp {
     {
       if (otherCC->state_ != state_) return false;
       SymbolicComponents_t::const_iterator it = std::find
-        (to_.begin(), to_.end(), otherCC);
+        (to_.begin(), to_.end(), otherCC.get());
       if (it == to_.end()) return false;
       it = std::find
-        (from_.begin(), from_.end(), otherCC);
+        (from_.begin(), from_.end(), otherCC.get());
       if (it == from_.end()) return false;
       return true;
     }
 
     void SymbolicComponent::canReach (const SymbolicComponentPtr_t& otherCC)
     {
-      to_.insert(otherCC);
-      otherCC->from_.insert(weak_.lock());
+      to_.insert(otherCC.get());
+      otherCC->from_.insert(this);
     }
 
     void SymbolicComponent::merge (SymbolicComponentPtr_t other)
@@ -79,11 +79,11 @@ namespace hpp {
       // Add other's nodes to this list.
       nodes_.insert (nodes_.end (), other->nodes_.begin(), other->nodes_.end());
 
-      from_.erase (other);
-      other->from_.erase (weak_.lock());
+      from_.erase (other.get());
+      other->from_.erase (this);
       from_.insert (other->from_.begin(), other->from_.end());
-      to_.erase (other);
-      other->to_.erase (weak_.lock());
+      to_.erase (other.get());
+      other->to_.erase (this);
       to_.insert (other->to_.begin(), other->to_.end());
     }
 
-- 
GitLab