mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-04 14:55:43 +02:00
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
This commit is contained in:
parent
5566c1a968
commit
421c0d139c
1 changed files with 17 additions and 7 deletions
|
@ -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);
|
||||||
|
|
||||||
|
// There are several reasons QGeoPositionInfoSource::createDefaultSource may return
|
||||||
|
// null. For example, if the device has no geolocation providers, or if the device has no
|
||||||
|
// location services activated. This seems to be the case for our QML testing fixture. Ideally,
|
||||||
|
// we would like to listen to system signals to know when location services are activated.
|
||||||
|
if (source_) {
|
||||||
connect(source_, &QGeoPositionInfoSource::errorOccurred, this, &Positioning::slotError);
|
connect(source_, &QGeoPositionInfoSource::errorOccurred, this, &Positioning::slotError);
|
||||||
connect(source_, &QGeoPositionInfoSource::positionUpdated, this, &Positioning::positionUpdated);
|
connect(source_,
|
||||||
// if location services are activated, positioning will be activated automatically
|
&QGeoPositionInfoSource::positionUpdated,
|
||||||
|
this,
|
||||||
|
&Positioning::positionUpdated);
|
||||||
|
// If location services are activated, positioning will be activated automatically.
|
||||||
connect(source_,
|
connect(source_,
|
||||||
&QGeoPositionInfoSource::supportedPositioningMethodsChanged,
|
&QGeoPositionInfoSource::supportedPositioningMethodsChanged,
|
||||||
this,
|
this,
|
||||||
&Positioning::locationServicesActivated);
|
&Positioning::locationServicesActivated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue