summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-08-08 10:34:13 +0300
committerAndrew Knight <andrew.knight@digia.com>2014-08-08 15:26:03 +0200
commit67dc29a96cf78ee4f4f2bfc42bfdde458138cd31 (patch)
tree560eebd8b8a4b1fb02d1bf5947f589ca26af8fc1 /src
parentb11494a1e51aba86ce945911ffbdc693a7eabff6 (diff)
downloadqtsensors-67dc29a96cf78ee4f4f2bfc42bfdde458138cd31.tar.gz
winrt: Avoid divide-by-zero when starting sensors
Several sensors were setting the dataRate without checking the value first. If the dataRate is zero, then don't set the native rate (use the default). Task-number: QTBUG-40664 Change-Id: I50e78fd071bd1f56e47baf23b74900b8a6e6c7eb Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/sensors/winrt/winrtaccelerometer.cpp7
-rw-r--r--src/plugins/sensors/winrt/winrtambientlightsensor.cpp7
-rw-r--r--src/plugins/sensors/winrt/winrtcompass.cpp7
-rw-r--r--src/plugins/sensors/winrt/winrtgyroscope.cpp7
-rw-r--r--src/plugins/sensors/winrt/winrtrotationsensor.cpp7
5 files changed, 30 insertions, 5 deletions
diff --git a/src/plugins/sensors/winrt/winrtaccelerometer.cpp b/src/plugins/sensors/winrt/winrtaccelerometer.cpp
index 7029f11..80d269c 100644
--- a/src/plugins/sensors/winrt/winrtaccelerometer.cpp
+++ b/src/plugins/sensors/winrt/winrtaccelerometer.cpp
@@ -172,7 +172,12 @@ void WinRtAccelerometer::start()
sensorError(hr);
return;
}
- quint32 reportInterval = qMax(d->minimumReportInterval, quint32(1000/sensor()->dataRate()));
+
+ int dataRate = sensor()->dataRate();
+ if (!dataRate)
+ return;
+
+ quint32 reportInterval = qMax(d->minimumReportInterval, quint32(1000/dataRate));
hr = d->sensor->put_ReportInterval(reportInterval);
if (FAILED(hr)) {
qCWarning(lcWinRtSensors) << "Unable to attach to set report interval."
diff --git a/src/plugins/sensors/winrt/winrtambientlightsensor.cpp b/src/plugins/sensors/winrt/winrtambientlightsensor.cpp
index 1164c9a..8929b2a 100644
--- a/src/plugins/sensors/winrt/winrtambientlightsensor.cpp
+++ b/src/plugins/sensors/winrt/winrtambientlightsensor.cpp
@@ -171,7 +171,12 @@ void WinRtAmbientLightSensor::start()
sensorError(hr);
return;
}
- quint32 reportInterval = qMax(d->minimumReportInterval, quint32(1000/sensor()->dataRate()));
+
+ int dataRate = sensor()->dataRate();
+ if (!dataRate)
+ return;
+
+ quint32 reportInterval = qMax(d->minimumReportInterval, quint32(1000/dataRate));
hr = d->sensor->put_ReportInterval(reportInterval);
if (FAILED(hr)) {
qCWarning(lcWinRtSensors) << "Unable to attach to set report interval."
diff --git a/src/plugins/sensors/winrt/winrtcompass.cpp b/src/plugins/sensors/winrt/winrtcompass.cpp
index 9a3a150..45aeedd 100644
--- a/src/plugins/sensors/winrt/winrtcompass.cpp
+++ b/src/plugins/sensors/winrt/winrtcompass.cpp
@@ -191,7 +191,12 @@ void WinRtCompass::start()
sensorError(hr);
return;
}
- quint32 reportInterval = qMax(d->minimumReportInterval, quint32(1000/sensor()->dataRate()));
+
+ int dataRate = sensor()->dataRate();
+ if (!dataRate)
+ return;
+
+ quint32 reportInterval = qMax(d->minimumReportInterval, quint32(1000/dataRate));
hr = d->sensor->put_ReportInterval(reportInterval);
if (FAILED(hr)) {
qCWarning(lcWinRtSensors) << "Unable to attach to set report interval."
diff --git a/src/plugins/sensors/winrt/winrtgyroscope.cpp b/src/plugins/sensors/winrt/winrtgyroscope.cpp
index 471ea7d..0b1cbb9 100644
--- a/src/plugins/sensors/winrt/winrtgyroscope.cpp
+++ b/src/plugins/sensors/winrt/winrtgyroscope.cpp
@@ -169,7 +169,12 @@ void WinRtGyroscope::start()
sensorError(hr);
return;
}
- quint32 reportInterval = qMax(d->minimumReportInterval, quint32(1000/sensor()->dataRate()));
+
+ int dataRate = sensor()->dataRate();
+ if (!dataRate)
+ return;
+
+ quint32 reportInterval = qMax(d->minimumReportInterval, quint32(1000/dataRate));
hr = d->sensor->put_ReportInterval(reportInterval);
if (FAILED(hr)) {
qCWarning(lcWinRtSensors) << "Unable to attach to set report interval."
diff --git a/src/plugins/sensors/winrt/winrtrotationsensor.cpp b/src/plugins/sensors/winrt/winrtrotationsensor.cpp
index 2e78601..e3616a9 100644
--- a/src/plugins/sensors/winrt/winrtrotationsensor.cpp
+++ b/src/plugins/sensors/winrt/winrtrotationsensor.cpp
@@ -167,7 +167,12 @@ void WinRtRotationSensor::start()
sensorError(hr);
return;
}
- quint32 reportInterval = qMax(d->minimumReportInterval, quint32(1000/sensor()->dataRate()));
+
+ int dataRate = sensor()->dataRate();
+ if (!dataRate)
+ return;
+
+ quint32 reportInterval = qMax(d->minimumReportInterval, quint32(1000/dataRate));
hr = d->sensor->put_ReportInterval(reportInterval);
if (FAILED(hr)) {
qCWarning(lcWinRtSensors) << "Unable to attach to set report interval."