Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix accelerometer crashing when config is not right.
[accelerometer] Fix accelerometer crashing with invalid config. Contributes to JB#32073

In case the config is not valid lets not crash the whole sensorfw
because accelerometer fails.

Signed-off-by: Marko Saukko <marko.saukko@jolla.com>
  • Loading branch information
saukko committed Aug 23, 2016
1 parent 6dd35ca commit e63f078
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions chains/accelerometerchain/accelerometerchain.cpp
Expand Up @@ -45,8 +45,9 @@ AccelerometerChain::AccelerometerChain(const QString& id) :
SensorManager& sm = SensorManager::instance();

accelerometerAdaptor_ = sm.requestDeviceAdaptor("accelerometeradaptor");
Q_ASSERT( accelerometerAdaptor_ );
setValid(accelerometerAdaptor_->isValid());

if (accelerometerAdaptor_)
setValid(accelerometerAdaptor_->isValid());

accelerometerReader_ = new BufferReader<AccelerationData>(1);

Expand Down Expand Up @@ -106,6 +107,11 @@ AccelerometerChain::~AccelerometerChain()

bool AccelerometerChain::start()
{
if (!accelerometerAdaptor_) {
sensordLogD() << "No accelerometer adaptor to start.";
return false;
}

if (AbstractSensorChannel::start()) {
sensordLogD() << "Starting AccelerometerChain";
filterBin_->start();
Expand All @@ -116,6 +122,11 @@ bool AccelerometerChain::start()

bool AccelerometerChain::stop()
{
if (!accelerometerAdaptor_) {
sensordLogD() << "No accelerometer adaptor to stop.";
return false;
}

if (AbstractSensorChannel::stop()) {
sensordLogD() << "Stopping AccelerometerChain";
accelerometerAdaptor_->stopSensor();
Expand Down

0 comments on commit e63f078

Please sign in to comment.