[Interest] App crashes on iOS when geocode or reverseGecode is used
Tony Rietwyk
tony at rightsoft.com.au
Sun Apr 14 06:54:55 CEST 2019
Hi Roman,
Your qGeoService provider is on the stack and discarded at the end of
your constructor. The documentation for geocodingManager makes clear
that the pointer returned is owned by the provider, so I assume the
pointer becomes invalid. Try keeping a pointer to the provider as well
as the coder.
Hope that helps, Tony
On 13/04/2019 4:54 am, Roman Wüger wrote:
>
> 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 <roman.wueger at gmx.at <mailto: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
>
> > Interest at qt-project.org <mailto:Interest at qt-project.org>
>
> > https://lists.qt-project.org/listinfo/interest
>
> _______________________________________________
>
> Interest mailing list
>
> Interest at qt-project.org <mailto:Interest at qt-project.org>
>
> https://lists.qt-project.org/listinfo/interest
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190414/8b53298c/attachment.html>
More information about the Interest
mailing list