From 4ac6f34b16aa404b8753d2ae1103da3605f33886 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 17 Apr 2016 22:50:33 -0700 Subject: With patched Qt 5.6 for iOS correctly handle disabled GPS source Qt 5.6.0 is broken when it comes to using CoreLocationService on iOS. It doesn't even check if the location service is enabled. My patches fix that and make Qt set an error code right after service creation. Having the service creation fail is actually the wrong thing to do because then Qt switches over to GeoClue and that really isn't helpful for our needs here. Additionally, Qt 5.6.0 without my patches doesn't follow the REQUIRED flow of using the location service as it does not check the access permissions before accessing the GPS service - without doing so the GPS service will not run in the background. Signed-off-by: Dirk Hohndel --- core/gpslocation.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core') diff --git a/core/gpslocation.cpp b/core/gpslocation.cpp index 29a8827af..2a097588a 100644 --- a/core/gpslocation.cpp +++ b/core/gpslocation.cpp @@ -58,6 +58,19 @@ QGeoPositionInfoSource *GpsLocation::getGpsSource() if (!m_GpsSource) { m_GpsSource = QGeoPositionInfoSource::createDefaultSource(this); if (m_GpsSource != 0) { +#if defined(Q_OS_IOS) + // at least Qt 5.6.0 isn't doing things right on iOS - it MUST check for permission before + // accessing the position source + // I have a hacked version of Qt 5.6.0 that I will build the iOS binaries with for now; + // this test below righ after creating the source checks if the location service is disabled + // and set's an error right when the position source is created to indicate this + if (m_GpsSource->error() == QGeoPositionInfoSource::AccessError) { + haveSource = NOGPS; + emit haveSourceChanged(); + m_GpsSource = NULL; + return NULL; + } +#endif haveSource = (m_GpsSource->supportedPositioningMethods() & QGeoPositionInfoSource::SatellitePositioningMethods) ? HAVEGPS : NOGPS; emit haveSourceChanged(); #ifndef SUBSURFACE_MOBILE -- cgit v1.2.3-70-g09d2