From 7ce27727c9a16503fd0d0b4eb9b7457de0dc9e08 Mon Sep 17 00:00:00 2001 From: Chi Huu Huynh <73843190+Chi-EEE@users.noreply.github.com> Date: Tue, 16 Apr 2024 14:20:05 +0100 Subject: [PATCH] Add checks for CameraDevice --- app/rpi/common/src/car/system/device/CameraDevice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/rpi/common/src/car/system/device/CameraDevice.cpp b/app/rpi/common/src/car/system/device/CameraDevice.cpp index 6849348a..6d33df1d 100644 --- a/app/rpi/common/src/car/system/device/CameraDevice.cpp +++ b/app/rpi/common/src/car/system/device/CameraDevice.cpp @@ -20,7 +20,7 @@ namespace car::system::device void CameraDevice::update() { std::lock_guard lock(this->camera_mutex_); - if (!this->connected_ || !this->camera_->isOpened()) { + if (!this->connected_ || this->camera_ == nullptr || !this->camera_->isOpened()) { this->frame_buffer_ = ""; return; } @@ -42,6 +42,7 @@ namespace car::system::device void CameraDevice::stop() { std::lock_guard lock(this->camera_mutex_); this->camera_->release(); + this->connected_ = false; } void CameraDevice::disconnect() {