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

hotfix: PT patch avoiding implicit destruction of last

parent 72e471de
No related branches found
No related tags found
2 merge requests!436Release to start wolf public,!433After 2nd RA-L submission
......@@ -114,6 +114,8 @@ class CaptureBase : public NodeBase, public HasStateBlocks, public std::enable_s
void move(FrameBasePtr);
void link(FrameBasePtr);
void unlink();
template<typename classType, typename... T>
static std::shared_ptr<classType> emplace(FrameBasePtr _frm_ptr, T&&... all);
......
......@@ -210,34 +210,41 @@ void CaptureBase::move(FrameBasePtr _frm_ptr)
assert((this->getFrame() == nullptr || not this->getFrame()->getProblem()) && "Forbidden: trying to move a capture already linked to a KF!");
// Unlink
if (this->getFrame())
{
// unlink from previous non-key frame
this->getFrame()->removeCapture(shared_from_this());
this->setFrame(nullptr);
}
unlink();
// link
link(_frm_ptr);
}
void CaptureBase::link(FrameBasePtr _frm_ptr)
{
assert(!is_removing_ && "linking a removed capture");
assert(this->getFrame() == nullptr && "linking a capture already linked");
WOLF_WARN_COND(_frm_ptr == nullptr, "Linking Capture ", id(), " to a nullptr");
if(_frm_ptr)
{
_frm_ptr->addCapture(shared_from_this());
this->setFrame(_frm_ptr);
this->setProblem(_frm_ptr->getProblem());
}
else
{
WOLF_WARN("Linking Capture ", id(), " to a nullptr");
}
}
void CaptureBase::unlink()
{
WOLF_WARN_COND(this->getFrame() == nullptr, "Unlinking a not linked Capture ", id(), ". Nothing to do, skipping...");
if (not this->getFrame())
return;
for (auto ftr : getFeatureList())
assert(ftr->getFactorList().empty() && " unlinking a capture with factors!");
assert(getConstrainedByList().empty() && " unlinking a capture constrained by factors!");
// unlink from frame
this->getFrame()->removeCapture(shared_from_this());
this->setFrame(nullptr);
}
void CaptureBase::setProblem(ProblemPtr _problem)
......
......@@ -252,7 +252,7 @@ void ProcessorTracker::processCapture(CaptureBasePtr _incoming_ptr)
getProblem()->getFrameStructure(),
last_ptr_->getFrame()->getState());
incoming_ptr_->link(frame);
last_ptr_->getFrame()->remove(); // implicitly calling last_ptr_->remove();
last_ptr_->unlink(); // unlink last (destroying the frame) instead of frame destruction that would implicitly destroy last
// Update pointers
last_ptr_ = incoming_ptr_;
......
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