summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Inwood <ainwood@blackberry.com>2014-04-01 13:40:08 -0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-09 22:24:39 +0200
commite60743e095b8bb7fcc3f0de823d2a46aa68343d3 (patch)
treee969b1a950ad61416a11710758967288da8b0b5a
parent2a503c28e4b9c9c05ee69e115f3530bb764844e3 (diff)
downloadqtsensors-e60743e095b8bb7fcc3f0de823d2a46aa68343d3.tar.gz
Android, Fix generic access to QAccelerometer
Generic access to QAccelerometer through QSensor was broken by my previous change: 971fc95eca1d9db93aa4bdb75793dfe83e4a97db When using a QSensor* to access the accelerometer, the qobject_cast would fail, and return 0. I fix this by defaulting the accelerationMode to Combined when a QSensor* is used. Change-Id: If8389808a416807b72709a13ca315aa23bbf94a0 Reviewed-by: Bernd Weimer <bweimer@blackberry.com> Reviewed-by: Fabian Bumberger <fbumberger@rim.com> Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
-rw-r--r--src/plugins/sensors/android/src/androidaccelerometer.cpp2
-rw-r--r--src/plugins/sensors/android/src/main.cpp7
2 files changed, 5 insertions, 4 deletions
diff --git a/src/plugins/sensors/android/src/androidaccelerometer.cpp b/src/plugins/sensors/android/src/androidaccelerometer.cpp
index 5a42d0c..76aa027 100644
--- a/src/plugins/sensors/android/src/androidaccelerometer.cpp
+++ b/src/plugins/sensors/android/src/androidaccelerometer.cpp
@@ -89,8 +89,8 @@ AndroidSensors::AndroidSensorType AndroidAccelerometer::modeToSensor(QAccelerome
case QAccelerometer::User:
type = AndroidSensors::TYPE_LINEAR_ACCELERATION;
break;
- default:
case QAccelerometer::Combined:
+ default:
type = AndroidSensors::TYPE_ACCELEROMETER;
break;
}
diff --git a/src/plugins/sensors/android/src/main.cpp b/src/plugins/sensors/android/src/main.cpp
index 3326208..3d8604f 100644
--- a/src/plugins/sensors/android/src/main.cpp
+++ b/src/plugins/sensors/android/src/main.cpp
@@ -112,10 +112,11 @@ public:
{
AndroidSensorType type = static_cast<AndroidSensorType>(sensor->identifier().toInt());
switch (type) {
- case TYPE_ACCELEROMETER:
- {
+ case TYPE_ACCELEROMETER: {
QAccelerometer * const accelerometer = qobject_cast<QAccelerometer *>(sensor);
- AndroidSensors::AndroidSensorType type = AndroidAccelerometer::modeToSensor(accelerometer->accelerationMode());
+ AndroidSensors::AndroidSensorType type
+ = accelerometer ? AndroidAccelerometer::modeToSensor(accelerometer->accelerationMode())
+ : AndroidSensors::TYPE_ACCELEROMETER;
return new AndroidAccelerometer(type, sensor);
}
case TYPE_AMBIENT_TEMPERATURE: