From b1590f25dcfde77d5298febb7cca2ca4f6e56385 Mon Sep 17 00:00:00 2001
From: jcasals <jcasals@iri.upc.edu>
Date: Fri, 8 May 2020 14:33:28 +0200
Subject: [PATCH] [WIP] Debug weak_ptr segfault

---
 include/core/processor/processor_motion.h | 4 ++--
 src/processor/processor_motion.cpp        | 4 ++--
 test/gtest_processor_base.cpp             | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/core/processor/processor_motion.h b/include/core/processor/processor_motion.h
index 3e127c9cb..ab0e9b9cf 100644
--- a/include/core/processor/processor_motion.h
+++ b/include/core/processor/processor_motion.h
@@ -466,7 +466,7 @@ class ProcessorMotion : public ProcessorBase, public IsMotion
                          bool state_blocks,
                          std::ostream& stream ,
                          std::string _tabs = "") const override;
-CaptureMotionPtr last_ptr_;
+
     protected:
         // Attributes
         SizeEigen x_size_;           ///< The size of the state vector
@@ -475,7 +475,7 @@ CaptureMotionPtr last_ptr_;
         SizeEigen delta_cov_size_;   ///< the size of the delta covariances matrix
         SizeEigen calib_size_;       ///< the size of the calibration parameters (TBD in derived classes)
         CaptureMotionPtr origin_ptr_;
-        
+        CaptureMotionPtr last_ptr_;
         CaptureMotionPtr incoming_ptr_;
 
     protected:
diff --git a/src/processor/processor_motion.cpp b/src/processor/processor_motion.cpp
index d8c6c1a44..36425f794 100644
--- a/src/processor/processor_motion.cpp
+++ b/src/processor/processor_motion.cpp
@@ -25,13 +25,13 @@ ProcessorMotion::ProcessorMotion(const std::string& _type,
         ProcessorBase(_type, _dim, _params_motion),
         params_motion_(_params_motion),
         processing_step_(RUNNING_WITHOUT_KF),
-        last_ptr_(),
         x_size_(_state_size),
         data_size_(_data_size),
         delta_size_(_delta_size),
         delta_cov_size_(_delta_cov_size),
         calib_size_(_calib_size),
         origin_ptr_(),
+        last_ptr_(),
         incoming_ptr_(),
         dt_(0.0), 
         x_(_state_size),
@@ -302,7 +302,7 @@ void ProcessorMotion::processCapture(CaptureBasePtr _incoming_ptr)
     // Update state and time stamps
     last_ptr_->setTimeStamp(getCurrentTimeStamp());
     auto test_last = last_ptr_->getFrame();
-    WOLF_TRACE("HELLO KITTY ", test_last == nullptr);
+    WOLF_TRACE("Is last_ptr_ null? ", test_last == nullptr);
     test_last->setTimeStamp(getCurrentTimeStamp());
     test_last->setState(getProblem()->getState(getCurrentTimeStamp()));
 
diff --git a/test/gtest_processor_base.cpp b/test/gtest_processor_base.cpp
index 5c62cac88..1665ca2df 100644
--- a/test/gtest_processor_base.cpp
+++ b/test/gtest_processor_base.cpp
@@ -116,9 +116,9 @@ TEST(ProcessorBase, KeyFrameCallback)
         capt_odo->setTimeStamp(t);
         std::cout << "2\n";
         problem->check(1);
-        auto proc_odo_motion = std::static_pointer_cast<ProcessorMotion>(proc_odo);
-        auto last_ptr = proc_odo_motion->last_ptr_;
-        auto last_ptr_frame = last_ptr->getFrame();
+//        auto proc_odo_motion = std::static_pointer_cast<ProcessorMotion>(proc_odo);
+//        auto last_ptr = proc_odo_motion->last_ptr_;
+//        auto last_ptr_frame = last_ptr->getFrame();
         proc_odo->captureCallback(capt_odo);
         std::cout << "3\n";
 
-- 
GitLab