summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorVyacheslav Koscheev <vok1980@gmail.com>2015-04-02 14:31:32 +0600
committerVyacheslav Koscheev <vok1980@gmail.com>2015-05-27 11:24:05 +0000
commit75f90d6dab7120b8595c7354acf213476be5646f (patch)
tree8048f1ed35c271c2202b5a8b6554bf54a0a9c361 /src/plugins
parent9526d2a937bfc06ab8f943c2e9edf449adbf8eef (diff)
downloadqtsensors-75f90d6dab7120b8595c7354acf213476be5646f.tar.gz
Fix crash in AndroidCompass
Change-Id: I9031610c02d9418b46339c34b02264a03600403c Task-number: QTBUG-45691 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/sensors/android/src/androidcompass.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/sensors/android/src/androidcompass.cpp b/src/plugins/sensors/android/src/androidcompass.cpp
index 60d8c01..c0b3547 100644
--- a/src/plugins/sensors/android/src/androidcompass.cpp
+++ b/src/plugins/sensors/android/src/androidcompass.cpp
@@ -45,6 +45,7 @@ public:
AndroidAccelerometerListener(AndroidCompass *parent)
: m_compass(parent)
{
+ memset(reading, 0, sizeof(reading));
}
void start(int dataRate)
@@ -84,7 +85,7 @@ public:
AndroidMagnetometerListener(AndroidCompass *parent)
:m_compass(parent)
{
-
+ memset(reading, 0, sizeof(reading));
}
void start(int dataRate)
@@ -138,9 +139,9 @@ void AndroidCompass::start()
{
if (!m_accelerometerListener)
m_accelerometerListener = new AndroidAccelerometerListener(this);
- m_accelerometerListener->start(sensor()->dataRate());
if (!m_magnetometerListener)
m_magnetometerListener = new AndroidMagnetometerListener(this);
+ m_accelerometerListener->start(sensor()->dataRate());
m_magnetometerListener->start(sensor()->dataRate());
m_isStarted = true;
@@ -157,6 +158,8 @@ void AndroidCompass::stop()
void AndroidCompass::testStuff()
{
+ if (!m_accelerometerListener || !m_magnetometerListener)
+ return;
qreal azimuth = AndroidSensors::getCompassAzimuth(m_accelerometerListener->reading, m_magnetometerListener->reading);
azimuth = azimuth * 180.0 / M_PI;