Skip to content
Snippets Groups Projects
Commit 34e0918e authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

small changes

parent 4b75206e
No related branches found
No related tags found
1 merge request!300Resolve "Robust remove() API"
This commit is part of merge request !300. Comments created here will be created in the context of that merge request.
......@@ -315,6 +315,7 @@ void CaptureBase::move(FrameBasePtr _frm_ptr)
void CaptureBase::link(FrameBasePtr _frm_ptr)
{
assert(!is_removing_ && "linking a removed capture");
assert(this->getFrame() == nullptr && "linking a capture already linked");
if(_frm_ptr)
......
......@@ -49,7 +49,7 @@ void FactorBase::remove()
if (!is_removing_)
{
is_removing_ = true;
FactorBasePtr this_c = shared_from_this(); // keep this alive while removing it
FactorBasePtr this_fac = shared_from_this(); // keep this alive while removing it
FeatureBasePtr f = feature_ptr_.lock();
if (f)
{
......@@ -59,13 +59,13 @@ void FactorBase::remove()
}
// add factor to be removed from solver
if (getProblem() != nullptr)
getProblem()->notifyFactor(shared_from_this(),REMOVE);
getProblem()->notifyFactor(this_fac,REMOVE);
// remove other: {Frame, Capture, Feature, Landmark}
FrameBasePtr frm_o = frame_other_ptr_.lock();
if (frm_o)
{
frm_o->removeConstrainedBy(shared_from_this());
frm_o->removeConstrainedBy(this_fac);
if (frm_o->getConstrainedByList().empty() && frm_o->getCaptureList().empty())
frm_o->remove();
}
......@@ -73,7 +73,7 @@ void FactorBase::remove()
CaptureBasePtr cap_o = capture_other_ptr_.lock();
if (cap_o)
{
cap_o->removeConstrainedBy(shared_from_this());
cap_o->removeConstrainedBy(this_fac);
if (cap_o->getConstrainedByList().empty() && cap_o->getFeatureList().empty())
cap_o->remove();
}
......@@ -81,7 +81,7 @@ void FactorBase::remove()
FeatureBasePtr ftr_o = feature_other_ptr_.lock();
if (ftr_o)
{
ftr_o->removeConstrainedBy(shared_from_this());
ftr_o->removeConstrainedBy(this_fac);
if (ftr_o->getConstrainedByList().empty() && ftr_o->getFactorList().empty())
ftr_o->remove();
}
......@@ -89,7 +89,7 @@ void FactorBase::remove()
LandmarkBasePtr lmk_o = landmark_other_ptr_.lock();
if (lmk_o)
{
lmk_o->removeConstrainedBy(shared_from_this());
lmk_o->removeConstrainedBy(this_fac);
if (lmk_o->getConstrainedByList().empty())
lmk_o->remove();
}
......@@ -143,6 +143,7 @@ void FactorBase::setStatus(FactorStatus _status)
void FactorBase::link(FeatureBasePtr _ftr_ptr)
{
assert(!is_removing_ && "linking a removed factor");
assert(this->getFeature() == nullptr && "linking an already linked factor");
// not link if nullptr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment