From 391bee554fd6984113b68e191894c88a75400ede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chehade=20Daniel=20=28=D0=A8=D0=B5=D1=85=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=20=D0=94=D0=B0=D0=BD=D0=B8=D1=8D=D0=BB=D1=8C=29?= <71555323+danielsheh02@users.noreply.github.com> Date: Fri, 27 Sep 2024 15:01:57 +0300 Subject: [PATCH] Remove reset the range sensor state You do not need to reset the sensor state if it has become a fail (it has become a fault for a reason). One example of a real error: due to the incorrect path to the device file, the sensor state became fail, after that, during initialization, this state was reset and when trying to read data from this sensor, the program terminated with SEGFAULT. --- trikControl/src/rangeSensor.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/trikControl/src/rangeSensor.cpp b/trikControl/src/rangeSensor.cpp index 66142db07..7172677b5 100644 --- a/trikControl/src/rangeSensor.cpp +++ b/trikControl/src/rangeSensor.cpp @@ -76,11 +76,9 @@ RangeSensor::Status RangeSensor::status() const void RangeSensor::init() { - if (mState.isFailed()) { - mState.resetFailure(); + if (!mState.isFailed()) { + QMetaObject::invokeMethod(mSensorWorker.data(), &RangeSensorWorker::init); } - - QMetaObject::invokeMethod(mSensorWorker.data(), &RangeSensorWorker::init); } int RangeSensor::read()