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"
...@@ -315,6 +315,7 @@ void CaptureBase::move(FrameBasePtr _frm_ptr) ...@@ -315,6 +315,7 @@ void CaptureBase::move(FrameBasePtr _frm_ptr)
void CaptureBase::link(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"); assert(this->getFrame() == nullptr && "linking a capture already linked");
if(_frm_ptr) if(_frm_ptr)
......
...@@ -49,7 +49,7 @@ void FactorBase::remove() ...@@ -49,7 +49,7 @@ void FactorBase::remove()
if (!is_removing_) if (!is_removing_)
{ {
is_removing_ = true; 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(); FeatureBasePtr f = feature_ptr_.lock();
if (f) if (f)
{ {
...@@ -59,13 +59,13 @@ void FactorBase::remove() ...@@ -59,13 +59,13 @@ void FactorBase::remove()
} }
// add factor to be removed from solver // add factor to be removed from solver
if (getProblem() != nullptr) if (getProblem() != nullptr)
getProblem()->notifyFactor(shared_from_this(),REMOVE); getProblem()->notifyFactor(this_fac,REMOVE);
// remove other: {Frame, Capture, Feature, Landmark} // remove other: {Frame, Capture, Feature, Landmark}
FrameBasePtr frm_o = frame_other_ptr_.lock(); FrameBasePtr frm_o = frame_other_ptr_.lock();
if (frm_o) if (frm_o)
{ {
frm_o->removeConstrainedBy(shared_from_this()); frm_o->removeConstrainedBy(this_fac);
if (frm_o->getConstrainedByList().empty() && frm_o->getCaptureList().empty()) if (frm_o->getConstrainedByList().empty() && frm_o->getCaptureList().empty())
frm_o->remove(); frm_o->remove();
} }
...@@ -73,7 +73,7 @@ void FactorBase::remove() ...@@ -73,7 +73,7 @@ void FactorBase::remove()
CaptureBasePtr cap_o = capture_other_ptr_.lock(); CaptureBasePtr cap_o = capture_other_ptr_.lock();
if (cap_o) if (cap_o)
{ {
cap_o->removeConstrainedBy(shared_from_this()); cap_o->removeConstrainedBy(this_fac);
if (cap_o->getConstrainedByList().empty() && cap_o->getFeatureList().empty()) if (cap_o->getConstrainedByList().empty() && cap_o->getFeatureList().empty())
cap_o->remove(); cap_o->remove();
} }
...@@ -81,7 +81,7 @@ void FactorBase::remove() ...@@ -81,7 +81,7 @@ void FactorBase::remove()
FeatureBasePtr ftr_o = feature_other_ptr_.lock(); FeatureBasePtr ftr_o = feature_other_ptr_.lock();
if (ftr_o) if (ftr_o)
{ {
ftr_o->removeConstrainedBy(shared_from_this()); ftr_o->removeConstrainedBy(this_fac);
if (ftr_o->getConstrainedByList().empty() && ftr_o->getFactorList().empty()) if (ftr_o->getConstrainedByList().empty() && ftr_o->getFactorList().empty())
ftr_o->remove(); ftr_o->remove();
} }
...@@ -89,7 +89,7 @@ void FactorBase::remove() ...@@ -89,7 +89,7 @@ void FactorBase::remove()
LandmarkBasePtr lmk_o = landmark_other_ptr_.lock(); LandmarkBasePtr lmk_o = landmark_other_ptr_.lock();
if (lmk_o) if (lmk_o)
{ {
lmk_o->removeConstrainedBy(shared_from_this()); lmk_o->removeConstrainedBy(this_fac);
if (lmk_o->getConstrainedByList().empty()) if (lmk_o->getConstrainedByList().empty())
lmk_o->remove(); lmk_o->remove();
} }
...@@ -143,6 +143,7 @@ void FactorBase::setStatus(FactorStatus _status) ...@@ -143,6 +143,7 @@ void FactorBase::setStatus(FactorStatus _status)
void FactorBase::link(FeatureBasePtr _ftr_ptr) void FactorBase::link(FeatureBasePtr _ftr_ptr)
{ {
assert(!is_removing_ && "linking a removed factor");
assert(this->getFeature() == nullptr && "linking an already linked factor"); assert(this->getFeature() == nullptr && "linking an already linked factor");
// not link if nullptr // 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