[Interest] App crashes on iOS when geocode or reverseGecode is used
Roman Wüger
roman.wueger at gmx.at
Fri Apr 12 20:54:47 CEST 2019
Hello Paolo,
Thanks for reply.
I use it so:
In the constructor I connect the signal from the geocoding manager
m_pGeoPositionUpdates = QGeoPositionInfoSource::createDefaultSource(this);
connect(m_pGeoPositionUpdates, &QGeoPositionInfoSource::positionUpdated, this, &MyClass::onPositionUpdated);
QGeoServiceProvider qGeoService("osm");
m_pQGeoCoder = qGeoService.geocodingManager();
m_pGeoPositionUpdates->startUpdates();
In the connected slot I will do this :
void MyClass::onPositionUpdated(const QGeoPositionInfo &positionUpdate) {
// QGeoLocation location;
// location.setCoordinate(positionUpdate.coordinate());
// QGeoAddress address(location.address());
// updateGeoAddress(address);
qDebug() << "Is Coord Valid: " << positionUpdate.coordinate().isValid();
qDebug() << "Coordinate: " << positionUpdate.coordinate();
if (m_pQGeoCoder) {
QGeoCodeReply *pQGeoCode = m_pQGeoCoder->reverseGeocode(positionUpdate.coordinate()); // CRASH
if (pQGeoCode) {
connect(pQGeoCode, &QGeoCodeReply::finished, [=]() {
if (pQGeoCode->error() == QGeoCodeReply::NoError) {
const QList<QGeoLocation> qGeoLocs = pQGeoCode->locations();
if (qGeoLocs.size() > 0) {
updateGeoAddress(qGeoLocs.first().address()); // This function handles the received address
}
}
else {
qDebug() << pQGeoCode->errorString();
}
});
}
}
}
Thanks in advance
Regards
Roman
-----Ursprüngliche Nachricht-----
Von: Interest <interest-bounces at qt-project.org> Im Auftrag von Paolo Angelelli
Gesendet: Freitag, 12. April 2019 15:37
An: interest at qt-project.org
Betreff: Re: [Interest] App crashes on iOS when geocode or reverseGecode is used
Hi, is the reply finished? do you get it from the finished signal of the manager?
Or are you trying to use what the method returns you immediately?
On Thu, 11 Apr 2019 22:42:36 +0200
Roman Wüger < <mailto:roman.wueger at gmx.at> roman.wueger at gmx.at> wrote:
> Hello,
>
> I try to get the city and country from coordinates.
> For this I use the functions geocode/reverseGecode. The pointer is valid but if the function is accessed with valid coordinates from the GeoPositionInfoSource signal, I get a EXC_BAD_ACCESS
>
> I use “osm” as the geo service provider.
>
> Any hints?
>
> Regards
> Roman
> _______________________________________________
> Interest mailing list
> <mailto:Interest at qt-project.org> Interest at qt-project.org
> <https://lists.qt-project.org/listinfo/interest> https://lists.qt-project.org/listinfo/interest
_______________________________________________
Interest mailing list
<mailto:Interest at qt-project.org> Interest at qt-project.org
<https://lists.qt-project.org/listinfo/interest> https://lists.qt-project.org/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190412/870c45d4/attachment.html>
More information about the Interest
mailing list