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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-04-17 22:50:33 -07:00
parent c0b44e25b7
commit 4ac6f34b16

View file

@ -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