From f16f4a231cd10867c10eb42fb456867469c93836 Mon Sep 17 00:00:00 2001 From: Alex Leung Date: Tue, 3 Mar 2020 10:25:48 -0500 Subject: Support custom Mapbox API base URLs Added support for custom Mapbox API base URLs. Fixes: QTBUG-82655 Change-Id: Ieebcc834f8aeaeb223b036100e5edadd55749101 Reviewed-by: Alex Blasche --- src/location/doc/src/plugins/mapboxgl.qdoc | 4 ++++ .../geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/location/doc/src/plugins/mapboxgl.qdoc b/src/location/doc/src/plugins/mapboxgl.qdoc index 119868d1..f2cea8e8 100644 --- a/src/location/doc/src/plugins/mapboxgl.qdoc +++ b/src/location/doc/src/plugins/mapboxgl.qdoc @@ -87,6 +87,10 @@ The following table lists optional parameters that can be passed to the Mapbox p When not set, a development token will be used by default. The development token is subject to the Mapbox \l{https://www.mapbox.com/tos}{Terms of Services} and must not be used in production. This property has no effect on styles hosted outside the Mapbox servers. +\row + \li mapboxgl.api_base_url + \li Set a custom API base URL. When not set, the URL defaults to \l{https://api.mapbox.com}. + This parameter is ignored if the the \b mapboxgl.china property is set. \row \li mapboxgl.china \li Use Mapbox China API base URLs and styles. diff --git a/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp index 5cbde041..cde7871e 100644 --- a/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp +++ b/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp @@ -73,6 +73,11 @@ QGeoMappingManagerEngineMapboxGL::QGeoMappingManagerEngineMapboxGL(const QVarian m_useChinaEndpoint = parameters.value(QStringLiteral("mapboxgl.china")).toBool(); } + if (parameters.contains(QStringLiteral("mapboxgl.api_base_url"))) { + const QString apiBaseUrl = parameters.value(QStringLiteral("mapboxgl.api_base_url")).toString(); + m_settings.setApiBaseUrl(apiBaseUrl); + } + QVariantMap metadata; metadata["isHTTPS"] = true; -- cgit v1.2.1 From ccfcf832862582cd0e7c6b33547c9bf9d3b47240 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 15 Jan 2020 15:13:27 +0100 Subject: winrt: Fix crash on exit Using a static ComPtr in requestAccess might cause a crash on exit as this pointer might be cleaned up after the application has exited. Make sure, that this pointer is deleted together with the rest by making it part of the d pointer. Fixes: QTBUG-80711 Change-Id: I93c09a4549967195101de07b3cef430f8cd52229 Reviewed-by: Andy Shaw Reviewed-by: Alex Blasche --- src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index a9cc164f..28a405c3 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -115,6 +115,7 @@ enum class InitializationState { class QGeoPositionInfoSourceWinRTPrivate { public: ComPtr locator; + mutable ComPtr statics; QTimer periodicTimer; QTimer singleUpdateTimer; QGeoPositionInfo lastPosition; @@ -638,21 +639,21 @@ HRESULT QGeoPositionInfoSourceWinRT::onStatusChanged(IGeolocator *, IStatusChang bool QGeoPositionInfoSourceWinRT::requestAccess() const { + Q_D(const QGeoPositionInfoSourceWinRT); qCDebug(lcPositioningWinRT) << __FUNCTION__; GeolocationAccessStatus accessStatus; - static ComPtr statics; ComPtr> op; HRESULT hr; - hr = QEventDispatcherWinRT::runOnXamlThread([&op]() { + hr = QEventDispatcherWinRT::runOnXamlThread([&op, d]() { HRESULT hr; - if (!statics) { + if (!d->statics) { hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Devices_Geolocation_Geolocator).Get(), - IID_PPV_ARGS(&statics)); + IID_PPV_ARGS(&d->statics)); RETURN_HR_IF_FAILED("Could not access Geolocation Statics."); } - hr = statics->RequestAccessAsync(&op); + hr = d->statics->RequestAccessAsync(&op); return hr; }); if (FAILED(hr)) { -- cgit v1.2.1 From 7711e7bcfae2c09688ecdaf587d580077889cce3 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 2 Apr 2020 14:41:39 +0200 Subject: Make use of qRegisterAnonymousType where possible Conincidentally the patch fixes a few other minor deprecation warnings in the same file too. Change-Id: Iaf6221cd35cca95415b7d5383477b8c2bcfe92b0 Reviewed-by: Fabian Kosmale --- src/imports/locationlabs/locationlabs.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/imports/locationlabs/locationlabs.cpp b/src/imports/locationlabs/locationlabs.cpp index 09fba284..4c039967 100644 --- a/src/imports/locationlabs/locationlabs.cpp +++ b/src/imports/locationlabs/locationlabs.cpp @@ -52,8 +52,8 @@ QT_BEGIN_NAMESPACE static QObject *singleton_type_factory(QQmlEngine *engine, QJSEngine *jsEngine) { - Q_UNUSED(engine); - Q_UNUSED(jsEngine); + Q_UNUSED(engine) + Q_UNUSED(jsEngine) return new LocationLabsSingleton; } @@ -66,7 +66,7 @@ class QtLocationLabsDeclarativeModule: public QQmlExtensionPlugin FILE "plugin.json") public: - QtLocationLabsDeclarativeModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } + QtLocationLabsDeclarativeModule(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { } virtual void registerTypes(const char *uri) { if (QLatin1String(uri) == QLatin1String("Qt.labs.location")) { @@ -82,9 +82,9 @@ public: qmlRegisterType(uri, major, minor, "MapCircleObject"); qmlRegisterType(uri, major, minor, "MapPolygonObject"); qmlRegisterType(uri, major, minor, "MapPolylineObject"); - qmlRegisterType(); + qmlRegisterAnonymousType(uri, major); qmlRegisterType(uri, major, minor, "Navigator"); - qmlRegisterType(); + qmlRegisterAnonymousType(uri, major); qmlRegisterSingletonType(uri, major, minor, "QtLocationLabs", singleton_type_factory); } else { qDebug() << "Unsupported URI given to load location QML plugin: " << QLatin1String(uri); -- cgit v1.2.1 From dd6df42a6ae90cd349b9af2d00d53c5a0d3ed1ed Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 2 Apr 2020 13:43:52 +0200 Subject: Fix QHash/QMultiHash related deprecations warnings Change-Id: I5ec9c700a0b69a556512efbd0bfd79c4c2119f9a Reviewed-by: Friedemann Kleint --- src/location/maps/qgeoserviceprovider.cpp | 8 ++++---- src/location/maps/qgeoserviceprovider_p.h | 4 ++-- src/positioning/qgeopositioninfosource.cpp | 8 ++++---- src/positioning/qgeopositioninfosource_p.h | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp index ec341c44..4873da22 100644 --- a/src/location/maps/qgeoserviceprovider.cpp +++ b/src/location/maps/qgeoserviceprovider.cpp @@ -896,9 +896,9 @@ void QGeoServiceProviderPrivate::loadPlugin(const QVariantMap ¶meters) } } -QHash QGeoServiceProviderPrivate::plugins(bool reload) +QMultiHash QGeoServiceProviderPrivate::plugins(bool reload) { - static QHash plugins; + static QMultiHash plugins; static bool alreadyDiscovered = false; if (reload == true) @@ -911,14 +911,14 @@ QHash QGeoServiceProviderPrivate::plugins(bool reload) return plugins; } -void QGeoServiceProviderPrivate::loadPluginMetadata(QHash &list) +void QGeoServiceProviderPrivate::loadPluginMetadata(QMultiHash &list) { QFactoryLoader *l = loader(); QList meta = l->metaData(); for (int i = 0; i < meta.size(); ++i) { QJsonObject obj = meta.at(i).value(QStringLiteral("MetaData")).toObject(); obj.insert(QStringLiteral("index"), i); - list.insertMulti(obj.value(QStringLiteral("Provider")).toString(), obj); + list.insert(obj.value(QStringLiteral("Provider")).toString(), obj); } } diff --git a/src/location/maps/qgeoserviceprovider_p.h b/src/location/maps/qgeoserviceprovider_p.h index c6b03ce5..22dcedd6 100644 --- a/src/location/maps/qgeoserviceprovider_p.h +++ b/src/location/maps/qgeoserviceprovider_p.h @@ -121,8 +121,8 @@ public: QLocale locale; bool localeSet; - static QHash plugins(bool reload = false); - static void loadPluginMetadata(QHash &list); + static QMultiHash plugins(bool reload = false); + static void loadPluginMetadata(QMultiHash &list); }; QT_END_NAMESPACE diff --git a/src/positioning/qgeopositioninfosource.cpp b/src/positioning/qgeopositioninfosource.cpp index 1f9abec1..56ee66d7 100644 --- a/src/positioning/qgeopositioninfosource.cpp +++ b/src/positioning/qgeopositioninfosource.cpp @@ -143,9 +143,9 @@ QVariant QGeoPositionInfoSourcePrivate::backendProperty(const QString &/*name*/) return QVariant(); } -QHash QGeoPositionInfoSourcePrivate::plugins(bool reload) +QMultiHash QGeoPositionInfoSourcePrivate::plugins(bool reload) { - static QHash plugins; + static QMultiHash plugins; static bool alreadyDiscovered = false; if (reload == true) @@ -179,7 +179,7 @@ QList QGeoPositionInfoSourcePrivate::pluginsSorted() return list; } -void QGeoPositionInfoSourcePrivate::loadPluginMetadata(QHash &plugins) +void QGeoPositionInfoSourcePrivate::loadPluginMetadata(QMultiHash &plugins) { QFactoryLoader *l = loader(); QList meta = l->metaData(); @@ -192,7 +192,7 @@ void QGeoPositionInfoSourcePrivate::loadPluginMetadata(QHash #include -#include +#include #include QT_BEGIN_NAMESPACE @@ -79,8 +79,8 @@ public: virtual bool setBackendProperty(const QString &name, const QVariant &value); virtual QVariant backendProperty(const QString &name) const; - static QHash plugins(bool reload = false); - static void loadPluginMetadata(QHash &list); + static QMultiHash plugins(bool reload = false); + static void loadPluginMetadata(QMultiHash &list); static QList pluginsSorted(); }; -- cgit v1.2.1 From f64813599bc4d1f57c964727e6b5b4ba3b6cb24a Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 1 Aug 2019 10:10:51 +0200 Subject: Fix Qt6 build Change-Id: Ib308cbc590d2a9203ac95a707870f7bd45b9bdea Reviewed-by: Simon Hausmann (cherry picked from commit f2fb9058b7053267f3c4b7a2bb5d1fe74fc358f7) Reviewed-by: Allan Sandfeld Jensen --- examples/location/mapviewer/main.cpp | 4 ++-- examples/location/places/main.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/location/mapviewer/main.cpp b/examples/location/mapviewer/main.cpp index b332de8c..ec54b5a2 100644 --- a/examples/location/mapviewer/main.cpp +++ b/examples/location/mapviewer/main.cpp @@ -66,8 +66,8 @@ static bool parseArgs(QStringList& args, QVariantMap& parameters) if (param.startsWith("--help")) { QTextStream out(stdout); - out << "Usage: " << endl; - out << "--plugin. - Sets parameter = value for plugin" << endl; + out << "Usage: " << Qt::endl; + out << "--plugin. - Sets parameter = value for plugin" << Qt::endl; out.flush(); return true; } diff --git a/examples/location/places/main.cpp b/examples/location/places/main.cpp index c677e429..69d31ae8 100644 --- a/examples/location/places/main.cpp +++ b/examples/location/places/main.cpp @@ -63,8 +63,8 @@ static bool parseArgs(QStringList& args, QVariantMap& parameters) if (param.startsWith("--help")) { QTextStream out(stdout); - out << "Usage: " << endl; - out << "--plugin. - Sets parameter = value for plugin" << endl; + out << "Usage: " << Qt::endl; + out << "--plugin. - Sets parameter = value for plugin" << Qt::endl; out.flush(); return true; } -- cgit v1.2.1 From eda2a7c286058176e1906d0ddc88d4e2cfbec55e Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 2 Apr 2020 13:58:09 +0200 Subject: Change QQmlListProperty ctor expecting a QList ptr This was introduced by 5a4ffa0de0ecc666a514ef60f0149a76d25b040d Change-Id: Icccf0c8cd3154c102fd93b79e81199e043f7d0bb Reviewed-by: Fabian Kosmale --- src/location/declarativemaps/qdeclarativegeomap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp index fc282829..875b8e47 100644 --- a/src/location/declarativemaps/qdeclarativegeomap.cpp +++ b/src/location/declarativemaps/qdeclarativegeomap.cpp @@ -1497,7 +1497,7 @@ QMargins QDeclarativeGeoMap::mapMargins() const */ QQmlListProperty QDeclarativeGeoMap::supportedMapTypes() { - return QQmlListProperty(this, m_supportedMapTypes); + return QQmlListProperty(this, &m_supportedMapTypes); } /*! -- cgit v1.2.1