From a8ca19baf8e2989742b65efb18e91802e3488685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= <jvallve@iri.upc.edu> Date: Wed, 26 Jun 2019 16:23:50 +0200 Subject: [PATCH] in FactorBase::link() skip if nullptr (not seting constrained by) --- src/factor/factor_base.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/factor/factor_base.cpp b/src/factor/factor_base.cpp index adec4caf9..4e29f0bf7 100644 --- a/src/factor/factor_base.cpp +++ b/src/factor/factor_base.cpp @@ -145,20 +145,22 @@ void FactorBase::link(FeatureBasePtr _ftr_ptr) { assert(this->getFeature() == nullptr && "linking an already linked factor"); - if(_ftr_ptr) + // not link if nullptr + if(_ftr_ptr == nullptr) { - _ftr_ptr->addFactor(shared_from_this()); - this->setFeature(_ftr_ptr); - this->setProblem(_ftr_ptr->getProblem()); - // add factor to be added in solver - if (this->getProblem() == nullptr) - { - WOLF_WARN("ADDING FACTOR ", this->id(), " TO FEATURE ", _ftr_ptr->id(), " NOT CONNECTED WITH PROBLEM."); - } - } - else WOLF_WARN("Linking with nullptr"); + return; + } + + // link with feature + _ftr_ptr->addFactor(shared_from_this()); + this->setFeature(_ftr_ptr); + + // set problem ( and register factor ) + WOLF_WARN_COND(this->getProblem() == nullptr, "ADDING FACTOR ", this->id(), " TO FEATURE ", _ftr_ptr->id(), " NOT CONNECTED WITH PROBLEM."); + this->setProblem(_ftr_ptr->getProblem()); + // constrained by auto frame_other = this->frame_other_ptr_.lock(); if(frame_other != nullptr) frame_other->addConstrainedBy(shared_from_this()); auto capture_other = this->capture_other_ptr_.lock(); -- GitLab