From d0177680f4926a27018fabd4a792f85c47261ce4 Mon Sep 17 00:00:00 2001 From: jcasals <jcasals@iri.upc.edu> Date: Thu, 7 May 2020 12:56:58 +0200 Subject: [PATCH] [WIP] Debug weak_ptr segfault --- include/core/capture/capture_base.h | 4 ++-- include/core/processor/processor_motion.h | 4 ++-- test/gtest_processor_base.cpp | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/core/capture/capture_base.h b/include/core/capture/capture_base.h index 9914ff93a..c6a91bbf5 100644 --- a/include/core/capture/capture_base.h +++ b/include/core/capture/capture_base.h @@ -176,8 +176,8 @@ inline unsigned int CaptureBase::id() const inline FrameBasePtr CaptureBase::getFrame() const { - frame_ptr_.expired(); - return frame_ptr_.lock(); + if(frame_ptr_.expired()) return nullptr; + else return frame_ptr_.lock(); } inline void CaptureBase::setFrame(const FrameBasePtr _frm_ptr) diff --git a/include/core/processor/processor_motion.h b/include/core/processor/processor_motion.h index ab0e9b9cf..3e127c9cb 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 @@ class ProcessorMotion : public ProcessorBase, public IsMotion 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/test/gtest_processor_base.cpp b/test/gtest_processor_base.cpp index 814ac262a..5c62cac88 100644 --- a/test/gtest_processor_base.cpp +++ b/test/gtest_processor_base.cpp @@ -116,6 +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(); proc_odo->captureCallback(capt_odo); std::cout << "3\n"; -- GitLab