mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-04 23:05:48 +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,14 +27,24 @@ Positioning::Positioning(QObject* parent)
|
|||
source_ = QGeoPositionInfoSource::createDefaultSource(this);
|
||||
timer_ = new QTimer(this);
|
||||
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::positionUpdated, this, &Positioning::positionUpdated);
|
||||
// if location services are activated, positioning will be activated automatically
|
||||
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
|
||||
Positioning::start()
|
||||
|
|
Loading…
Add table
Reference in a new issue