Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void BaseComponent::addSlave(BaseComponent::SPtr s)
const BaseComponent::SPtr previous = s->getMaster();
if (previous == this) return;
if (previous)
previous->l_slaves.remove(s);
previous->l_slaves.remove(s.get());
l_slaves.add(s);
if (previous)
this->getContext()->notifyMoveSlave(previous.get(), this, s.get());
Expand All @@ -234,7 +234,7 @@ void BaseComponent::addSlave(BaseComponent::SPtr s)

void BaseComponent::removeSlave(BaseComponent::SPtr s)
{
if (l_slaves.remove(s))
if (l_slaves.remove(s.get()))
{
this->getContext()->notifyRemoveSlave(this, s.get());
}
Expand Down
3 changes: 3 additions & 0 deletions Sofa/framework/Core/src/sofa/core/objectmodel/BaseLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ class SOFA_CORE_API BaseLink
/// Change the link's target at the provided index.
bool set(Base* baseptr, size_t index=0) { return _doSet_(baseptr, index); }

bool remove(Base* baseptr) {return _doRemove_(baseptr); }

protected:
virtual bool _doSet_(Base* target, const size_t index=0) = 0;
virtual Base* _doGetOwner_() const = 0 ;
Expand All @@ -183,6 +185,7 @@ class SOFA_CORE_API BaseLink
virtual bool _doAdd_(Base* target, const std::string&) = 0;
virtual void _doClear_() = 0;
virtual std::string _doGetLinkedPath_(const size_t=0) const = 0;
virtual bool _doRemove_(Base* target) = 0;

unsigned int m_flags;
std::string m_name;
Expand Down
6 changes: 3 additions & 3 deletions Sofa/framework/Core/src/sofa/core/objectmodel/Link.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,11 @@ class TLink : public BaseLink
return add(ptr, path);
}

bool remove(DestPtr v)
bool _doRemove_(Base* target) override
{
if (!v)
if (!target)
return false;
return removeAt(TraitsContainer::find(m_value,v));
return removeAt(TraitsContainer::find(m_value,castTo<DestType*>(target)));
}

bool removeAt(std::size_t index)
Expand Down
4 changes: 2 additions & 2 deletions Sofa/framework/Simulation/Core/src/sofa/simulation/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ bool Node::doRemoveObject(sofa::core::objectmodel::BaseComponent::SPtr sobj)
dmsg_warning_when(sobj == nullptr) << "Trying to remove a nullptr object";

this->clearObjectContext(sobj);
object.remove(sobj);
object.remove(sobj.get());
sofa::core::objectmodel::BaseComponent* obj = sobj.get();

if(obj != nullptr && !obj->removeInNode( this ) )
Expand Down Expand Up @@ -1185,7 +1185,7 @@ void Node::doRemoveChild(BaseNode::SPtr node)
{
const Node::SPtr dagnode = sofa::core::objectmodel::SPtr_static_cast<Node>(node);
setDirtyDescendancy();
child.remove(dagnode);
child.remove(dagnode.get());
dagnode->l_parents.remove(this);
}

Expand Down