From bbc15a07a17e9619d314e5cca1fbe3307ac36cd6 Mon Sep 17 00:00:00 2001 From: Slider0007 <115730895+Slider0007@users.noreply.github.com> Date: Fri, 10 Jan 2025 09:40:50 +0100 Subject: [PATCH] fix(demo mode): Deinit demo mode when main init is aborted (#198) --- code/components/camera_ctrl/ClassControlCamera.cpp | 6 ++---- code/components/mainprocess_ctrl/ClassFlowTakeImage.cpp | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/code/components/camera_ctrl/ClassControlCamera.cpp b/code/components/camera_ctrl/ClassControlCamera.cpp index bd5be5f66..786d19988 100644 --- a/code/components/camera_ctrl/ClassControlCamera.cpp +++ b/code/components/camera_ctrl/ClassControlCamera.cpp @@ -1142,14 +1142,12 @@ bool ClassControlCamera::loadNextDemoImage(camera_fb_t *_fb) /* Free only user allocated memory without deinit of cam driver */ void ClassControlCamera::freeDemoMemoryOnly() { - demoFiles.clear(); - std::vector().swap(demoFiles); // Ensure that memory allocated by vector gets freed + disableDemoMode(); } ClassControlCamera::~ClassControlCamera() { + disableDemoMode(); deinitCam(); - demoFiles.clear(); - std::vector().swap(demoFiles); // Ensure that memory allocated by vector gets freed } diff --git a/code/components/mainprocess_ctrl/ClassFlowTakeImage.cpp b/code/components/mainprocess_ctrl/ClassFlowTakeImage.cpp index dfb117193..5af0c3cab 100644 --- a/code/components/mainprocess_ctrl/ClassFlowTakeImage.cpp +++ b/code/components/mainprocess_ctrl/ClassFlowTakeImage.cpp @@ -172,4 +172,5 @@ time_t ClassFlowTakeImage::getTimeImageTaken() ClassFlowTakeImage::~ClassFlowTakeImage() { delete rawImage; + cameraCtrl.freeDemoMemoryOnly(); }