Skip to content
Snippets Groups Projects
Commit 421c0d13 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

positioning: handle cases where no default source is available

In this case we simply don't connect to a null object pointer.

This was causing invalid connections during test setup.

Gitlab: #899
Change-Id: I1c38c9338451f6817444576b95809c19bb28e3ff
parent 5566c1a9
No related branches found
No related tags found
No related merge requests found
...@@ -27,13 +27,23 @@ Positioning::Positioning(QObject* parent) ...@@ -27,13 +27,23 @@ Positioning::Positioning(QObject* parent)
source_ = QGeoPositionInfoSource::createDefaultSource(this); source_ = QGeoPositionInfoSource::createDefaultSource(this);
timer_ = new QTimer(this); timer_ = new QTimer(this);
connect(timer_, &QTimer::timeout, this, &Positioning::requestPosition); connect(timer_, &QTimer::timeout, this, &Positioning::requestPosition);
connect(source_, &QGeoPositionInfoSource::errorOccurred, this, &Positioning::slotError);
connect(source_, &QGeoPositionInfoSource::positionUpdated, this, &Positioning::positionUpdated); // There are several reasons QGeoPositionInfoSource::createDefaultSource may return
// if location services are activated, positioning will be activated automatically // null. For example, if the device has no geolocation providers, or if the device has no
connect(source_, // location services activated. This seems to be the case for our QML testing fixture. Ideally,
&QGeoPositionInfoSource::supportedPositioningMethodsChanged, // we would like to listen to system signals to know when location services are activated.
this, if (source_) {
&Positioning::locationServicesActivated); connect(source_, &QGeoPositionInfoSource::errorOccurred, this, &Positioning::slotError);
connect(source_,
&QGeoPositionInfoSource::positionUpdated,
this,
&Positioning::positionUpdated);
// If location services are activated, positioning will be activated automatically.
connect(source_,
&QGeoPositionInfoSource::supportedPositioningMethodsChanged,
this,
&Positioning::locationServicesActivated);
}
} }
void void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment