summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2018-12-19 16:18:34 +0100
committerAlex Blasche <alexander.blasche@qt.io>2019-01-04 14:12:02 +0000
commitb14145e3fe1bda9af80b043a3b0642510435fc7f (patch)
treebbfe46bf3948bcd01e67cb8794e46359f36576e0
parent3c3be256cc1658b0d02047b158228fd55d04e2a0 (diff)
downloadqtlocation-b14145e3fe1bda9af80b043a3b0642510435fc7f.tar.gz
Prevent potential blockage of setPreferredPositioningMethods()
This is useful because on several platforms supportedPositioningMethods() returns NoPositioningMethods while the user has disabled the Location service. At the same time the platforms can only support dynamic supportedPositioningMethodsChanged() notifications after startUpdates() was called. Blocking changes to this property would have been counterproductive as startUpdates() would always fail and notification would not be possible. This affects at least WinRT and Android and Apple platforms need still further investigation. Task-number: QTBUG-66427 Change-Id: Ie03a3ef9c9476d7be3547661eaa87678fdb7b39c Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--src/positioning/qgeopositioninfosource.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/positioning/qgeopositioninfosource.cpp b/src/positioning/qgeopositioninfosource.cpp
index 0230e4ca..2e126175 100644
--- a/src/positioning/qgeopositioninfosource.cpp
+++ b/src/positioning/qgeopositioninfosource.cpp
@@ -241,8 +241,10 @@ int QGeoPositionInfoSource::updateInterval() const
If \a methods includes a method that is not supported by the source, the
unsupported method will be ignored.
- If \a methods does not include any methods supported by the source, the
- preferred methods will be set to the set of methods which the source supports.
+ If \a methods does not include a single method available/supported by the source, the
+ preferred methods will be set to the set of methods which the source has available.
+ If the source has no method availabe (e.g. because its Location service is turned off
+ or it does not offer a Location service), the passed \a methods are accepted as they are.
\b {Note:} When reimplementing this method, subclasses must call the
base method implementation to ensure preferredPositioningMethods() returns the correct value.
@@ -251,9 +253,13 @@ int QGeoPositionInfoSource::updateInterval() const
*/
void QGeoPositionInfoSource::setPreferredPositioningMethods(PositioningMethods methods)
{
- d->methods = methods & supportedPositioningMethods();
- if (d->methods == 0) {
- d->methods = supportedPositioningMethods();
+ if (supportedPositioningMethods() != QGeoPositionInfoSource::NoPositioningMethods) {
+ d->methods = methods & supportedPositioningMethods();
+ if (d->methods == 0) {
+ d->methods = supportedPositioningMethods();
+ }
+ } else { // avoid that turned of Location service blocks any changes to d->methods
+ d->methods = methods;
}
}