From ee700d2eeb4508aa5356ddef11bf11964c5d9283 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 19 Oct 2018 09:24:36 +0200 Subject: Mapbox: Only include matching categories in the results If an entry in the results had no categories specified at all then it would end up including this in the results even if a specific category was requested to match against. Change-Id: I506b40b73ec07608bd2b2562d92065376fbb67c9 Reviewed-by: Paolo Angelelli --- src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp index a79af1cb..b2f2f043 100644 --- a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp +++ b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp @@ -188,19 +188,18 @@ void QPlaceSearchReplyMapbox::onReplyFinished() if (!categories.isEmpty()) { const QList placeCategories = placeResult.place().categories(); + bool categoryMatch = false; if (!placeCategories.isEmpty()) { - bool categoryMatch = false; for (const QPlaceCategory &placeCategory : placeCategories) { if (categories.contains(placeCategory)) { categoryMatch = true; break; } } - if (!categoryMatch) - continue; } + if (!categoryMatch) + continue; } - placeResult.setDistance(searchCenter.distanceTo(placeResult.place().location().coordinate())); results.append(placeResult); } -- cgit v1.2.1 From f777e851f5992a3b813e0d0c68f947c2a2f764fa Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Wed, 31 Oct 2018 11:13:13 +0200 Subject: Add changes file for Qt 5.12.0 Change-Id: Ib5609e2fa3d76c7372a0362502288eac6eee282a Reviewed-by: Alex Blasche --- dist/changes-5.12.0 | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 dist/changes-5.12.0 diff --git a/dist/changes-5.12.0 b/dist/changes-5.12.0 new file mode 100644 index 00000000..4fd5b693 --- /dev/null +++ b/dist/changes-5.12.0 @@ -0,0 +1,52 @@ +Qt 5.12 introduces many new features and improvements as well as bugfixes +over the 5.11.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.12 series is binary compatible with the 5.11.x series. +Applications compiled for 5.11 will continue to run with 5.12. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* QtLocation * +**************************************************************************** + + + - Added QDeclarativeGeoRoute::equals to perform deep comparisons in QML. + - MapItemView now exposes add and remove transitions, so that they can + be changed (defaults are none for add, and item fade out for remove). + - Enabled incremental updates in PlaceSearchModel, which prevents previousPage or + nextPage from resetting the model, but rather appending the new data to it. + - [QTBUG-68966] Added Map.visibleArea property. + - [QTBUG-62683][QTBUG-62397] Enabled nesting of MapItemView. This required + a behavioral change, as MapItemView is now a MapItemGroup, not anymore a + plain QObject. Due to a bug, MapItemView was previously not a Qt Quick + Item, making it possible to create it as a child of any QObject. This + has now been fixed, so if you happen to have a MapItemView in your scene + which is not a child of a Qt Quick Item, you will get an error message. + - Enabled asynchronous incremental updates of QPlaceReply. + - Changed QDeclarativeGeoMapItemBase::geoShape property from read-only into R/W. + - Added support for route legs. + - [QTBUG-70499] Fixed HERE plugin requesting the route incorrectly. + - Added ESRI place search manager to the ESRI plugin. + +**************************************************************************** +* QtPositioning * +**************************************************************************** + + - Exposed mercatorToCoord and coordToMercator to QML. + - [QTBUG-62875] QGeoPath can now be cleared directly using clearPath. + - Added QGeoPolygon::perimeter property. + - Added holes support to QGeoPolygon. Currently visualized only when using + in a MapPolygon with the MapboxGL plugin. + - [QTBUG-43435] Added Geoclue2 position plugin. + - [QTBUG-52660] QtPositioning now properly checks for authorization on iOS. + -- cgit v1.2.1 From 25c6840ff6585ca9f7ab1c168cdcdd18a68c7885 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 8 Nov 2018 11:27:24 +0100 Subject: Bump version Change-Id: I9eb138dde3677e25a6c40681bd2e1f7fa4765d10 --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index d478439a..634dfd52 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,4 +1,4 @@ load(qt_build_config) CONFIG += warning_clean -MODULE_VERSION = 5.11.2 +MODULE_VERSION = 5.11.3 -- cgit v1.2.1 From dc761b9007416b254eba18a300c5d7f91ca1c552 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Fri, 9 Nov 2018 21:28:23 +0100 Subject: QGeoPath: revert clear API to clearPath The original name was correct as clear would need to reset more properties which is was not the goal of this method. Change-Id: Iac43a61e4b8bf57220c88d627b33578612c4ddad Reviewed-by: Lars Knoll --- src/positioning/qgeopath.cpp | 2 +- src/positioning/qgeopath.h | 2 +- tests/auto/qgeopath/tst_qgeopath.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp index beb43692..0c3d0c1c 100644 --- a/src/positioning/qgeopath.cpp +++ b/src/positioning/qgeopath.cpp @@ -204,7 +204,7 @@ const QList &QGeoPath::path() const \since 5.12 */ -void QGeoPath::clear() +void QGeoPath::clearPath() { Q_D(QGeoPath); d->clearPath(); diff --git a/src/positioning/qgeopath.h b/src/positioning/qgeopath.h index cda6f277..e4af2add 100644 --- a/src/positioning/qgeopath.h +++ b/src/positioning/qgeopath.h @@ -72,7 +72,7 @@ public: void setPath(const QList &path); const QList &path() const; - void clear(); + void clearPath(); void setVariantPath(const QVariantList &path); QVariantList variantPath() const; diff --git a/tests/auto/qgeopath/tst_qgeopath.cpp b/tests/auto/qgeopath/tst_qgeopath.cpp index 213af0ad..47badf73 100644 --- a/tests/auto/qgeopath/tst_qgeopath.cpp +++ b/tests/auto/qgeopath/tst_qgeopath.cpp @@ -182,7 +182,7 @@ void tst_QGeoPath::path() QCOMPARE(p.path().contains(c), true); } - p.clear(); + p.clearPath(); QCOMPARE(p.path().size(), 0); QVERIFY(p.boundingGeoRectangle().isEmpty()); } -- cgit v1.2.1 From 85df79b094d1097108a28424d6f9b3b76b3aee62 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 8 Nov 2018 15:26:57 +0900 Subject: Fix unstable rotation gesture Order of touch events are not sorted on some platform. When touch point 1 and 2 are swapped, map is rotated 180 degrees in a moment Change-Id: I9c308b805a6ca54519f26a9ff19217de7f947c17 Reviewed-by: Paolo Angelelli --- src/location/declarativemaps/qquickgeomapgesturearea.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/location/declarativemaps/qquickgeomapgesturearea.cpp b/src/location/declarativemaps/qquickgeomapgesturearea.cpp index c6f4b42f..576aeeea 100644 --- a/src/location/declarativemaps/qquickgeomapgesturearea.cpp +++ b/src/location/declarativemaps/qquickgeomapgesturearea.cpp @@ -1087,6 +1087,7 @@ void QQuickGeoMapGestureArea::update() m_allPoints << m_touchPoints; if (m_allPoints.isEmpty() && !m_mousePoint.isNull()) m_allPoints << *m_mousePoint.data(); + std::sort(m_allPoints.begin(), m_allPoints.end(), [](const QTouchEvent::TouchPoint &tp1, const QTouchEvent::TouchPoint &tp2) { return tp1.id() < tp2.id(); }); touchPointStateMachine(); -- cgit v1.2.1 From d9985cd5a308cece06a88e6203529837f00b33aa Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Wed, 3 Oct 2018 12:56:18 +0200 Subject: Fix missing geometry update when changing border width In this case, only border geometry was marked dirty, producing a misplaced polygon. Fixes: QTBUG-70886 Change-Id: Ied39e523a584976871a655e436daf8c2700458b6 Reviewed-by: Alex Blasche --- src/location/declarativemaps/qdeclarativepolygonmapitem.cpp | 13 ++----------- src/location/declarativemaps/qdeclarativepolygonmapitem_p.h | 1 - 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp index c0d7f24b..e9f91e45 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp @@ -320,18 +320,9 @@ QDeclarativePolygonMapItem::QDeclarativePolygonMapItem(QQuickItem *parent) { setFlag(ItemHasContents, true); QObject::connect(&border_, SIGNAL(colorChanged(QColor)), - this, SLOT(handleBorderUpdated())); + this, SLOT(markSourceDirtyAndUpdate())); QObject::connect(&border_, SIGNAL(widthChanged(qreal)), - this, SLOT(handleBorderUpdated())); -} - -/*! - \internal -*/ -void QDeclarativePolygonMapItem::handleBorderUpdated() -{ - borderGeometry_.markSourceDirty(); - polishAndUpdate(); + this, SLOT(markSourceDirtyAndUpdate())); } QDeclarativePolygonMapItem::~QDeclarativePolygonMapItem() diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h index 83983651..60e81b08 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h @@ -118,7 +118,6 @@ protected: protected Q_SLOTS: void markSourceDirtyAndUpdate(); - void handleBorderUpdated(); virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) override; private: -- cgit v1.2.1 From ffac0dc5a60c93663f6a4ea5483422c58cdb52b6 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 16 Nov 2018 09:22:25 +0200 Subject: Add changes file for Qt 5.11.3 + ce1767d724e26012cfcd2eae0143ec9a87984046 Use the correct name for the resource when building statically + 8a7bde9b93208259de65d6b1aef21d21b495b6d7 If a category has UnspecifiedVisibility then we should still match + f9a1c4a18a3421617e28d2c26d30b011d22a0229 Amend 8a7bde9b93 to correctly account for the UnspecifiedVisibility case + 6b109d09982e09940dc8e777430a04410d7b6550 Fix crash when calling QGeoPath::length on empty QGeoPath instance + ee700d2eeb4508aa5356ddef11bf11964c5d9283 Mapbox: Only include matching categories in the results + 25c6840ff6585ca9f7ab1c168cdcdd18a68c7885 Bump version Change-Id: Ie25e5020441b8e0b2b2dcb8f2fc56d68681c69a0 Reviewed-by: Kai Koehne --- dist/changes-5.11.3 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 dist/changes-5.11.3 diff --git a/dist/changes-5.11.3 b/dist/changes-5.11.3 new file mode 100644 index 00000000..9b09a0c0 --- /dev/null +++ b/dist/changes-5.11.3 @@ -0,0 +1,32 @@ +Qt 5.11.3 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.11.0 through 5.11.2. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.11 series is binary compatible with the 5.10.x series. +Applications compiled for 5.10 will continue to run with 5.11. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Qt 5.11.3 Changes * +**************************************************************************** + + QtLocation + ---------- + + - [QTBUG-69617] Fixed Qt.labs.location not linking statically on iOS. + - [QTBUG-71355] Fixed crash when calling QGeoPath::length() on empty + QGeoPath instance. + - Fixed place search matching based on category in mapbox plugin. Previously, + the search results contained places which did not have any category set. + -- cgit v1.2.1 From cb19e1f7e3cc2cfee3b8fcbdfa5cd151826dadac Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Mon, 26 Nov 2018 13:40:13 +0100 Subject: Fix error handling in QGeoServiceProvider A dangerous local reference with the same name of a member variable caused the latter not to be evaluated and the former not to be set. Change-Id: Iaadcc3bce36f56ed8eeb77374687cf33632abd2f Reviewed-by: Alex Blasche --- src/location/maps/qgeoserviceprovider.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp index c6b9d742..27332e88 100644 --- a/src/location/maps/qgeoserviceprovider.cpp +++ b/src/location/maps/qgeoserviceprovider.cpp @@ -362,7 +362,7 @@ template <> QNavigationManagerEngine *createEngine(QGe { if (!d_ptr->factoryV2) return nullptr; - return d_ptr->factoryV2->createNavigationManagerEngine(d_ptr->cleanedParameterMap, &(d_ptr->placeError), &(d_ptr->placeErrorString)); + return d_ptr->factoryV2->createNavigationManagerEngine(d_ptr->cleanedParameterMap, &(d_ptr->navigationError), &(d_ptr->navigationErrorString)); } /* Template for generating the code for each of the geocodingManager(), @@ -381,11 +381,15 @@ Manager *QGeoServiceProviderPrivate::manager(QGeoServiceProvider::Error *_error, this->loadPlugin(this->parameterMap); } - if (!this->factory || error != QGeoServiceProvider::NoError) + if (!this->factory || this->error != QGeoServiceProvider::NoError) { + error = this->error; + errorString = this->errorString; return 0; + } if (!manager) { - Engine *engine = createEngine(this); + Engine *engine = createEngine(this); // this sets the specific error variables directly, + // from now on the local error, errorString refs should be set. if (engine) { engine->setManagerName( @@ -753,7 +757,7 @@ void QGeoServiceProviderPrivate::loadPlugin(const QVariantMap ¶meters) QObject *instance = loader()->instance(idx); if (!instance) { error = QGeoServiceProvider::LoaderError; - errorString = QLatin1String("loader()->instance(idx) failed to return an instance"); + errorString = QLatin1String("loader()->instance(idx) failed to return an instance. Set the environment variable QT_DEBUG_PLUGINS to see more details."); return; } factoryV3 = qobject_cast(instance); -- cgit v1.2.1 From a4cc61fc30cb7dff15bf7ae2ff064530b40d72c5 Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Tue, 6 Nov 2018 13:48:27 +0100 Subject: Improve the initialization behavior of CategoryModel CategoryModel was missing an update call in the ::componentComplete callback, as well as reacting on the name changed signal of the plugin. An update call was also missing in the setPlugin method. This patch makes it react on the attached signal instead, and adds missing update calls. Fixes: QTBUG-70254 Change-Id: I1a8de0137b4fe4af7c5ffc848799061147febba2 Reviewed-by: Michael Brasser --- .../qdeclarativesupportedcategoriesmodel.cpp | 29 ++++++++++++++++++---- tests/auto/declarative_core/tst_categorymodel.qml | 5 ++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp b/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp index b7c6e319..3bc45c4f 100644 --- a/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp +++ b/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp @@ -39,6 +39,7 @@ #include "qdeclarativeplaceicon_p.h" #include "qgeoserviceprovider.h" #include "error_messages_p.h" +#include #include #include @@ -120,6 +121,15 @@ QT_BEGIN_NAMESPACE textual representation. */ +/*! + \qmlmethod void QtLocation::CategoryModel::update() + \internal + + Updates the model. + + \note The CategoryModel auto updates automatically when needed. Calling this method explicitly is normally not necessary. +*/ + /*! \internal \enum QDeclarativeSupportedCategoriesModel::Roles @@ -143,6 +153,8 @@ QDeclarativeSupportedCategoriesModel::~QDeclarativeSupportedCategoriesModel() void QDeclarativeSupportedCategoriesModel::componentComplete() { m_complete = true; + if (m_plugin) // do not try to load or change status when trying to update in componentComplete() if the plugin hasn't been set yet even once. + update(); } /*! @@ -255,6 +267,7 @@ void QDeclarativeSupportedCategoriesModel::setPlugin(QDeclarativeGeoServiceProvi //disconnect the manager of the old plugin if we have one if (m_plugin) { + disconnect(m_plugin, nullptr, this, nullptr); QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider(); if (serviceProvider) { QPlaceManager *placeManager = serviceProvider->placeManager(); @@ -273,14 +286,17 @@ void QDeclarativeSupportedCategoriesModel::setPlugin(QDeclarativeGeoServiceProvi m_plugin = plugin; - // handle plugin name changes -> update categories + // handle plugin attached changes -> update categories if (m_plugin) { - connect(m_plugin, SIGNAL(nameChanged(QString)), this, SLOT(connectNotificationSignals())); - connect(m_plugin, SIGNAL(nameChanged(QString)), this, SLOT(update())); + if (m_plugin->isAttached()) { + connectNotificationSignals(); + update(); + } else { + connect(m_plugin, &QDeclarativeGeoServiceProvider::attached, this, &QDeclarativeSupportedCategoriesModel::update); + connect(m_plugin, &QDeclarativeGeoServiceProvider::attached, this, &QDeclarativeSupportedCategoriesModel::connectNotificationSignals); + } } - connectNotificationSignals(); - if (m_complete) emit pluginChanged(); } @@ -499,6 +515,9 @@ void QDeclarativeSupportedCategoriesModel::connectNotificationSignals() */ void QDeclarativeSupportedCategoriesModel::update() { + if (!m_complete) + return; + if (m_response) return; diff --git a/tests/auto/declarative_core/tst_categorymodel.qml b/tests/auto/declarative_core/tst_categorymodel.qml index 0b6e50a3..86d0fd4c 100644 --- a/tests/auto/declarative_core/tst_categorymodel.qml +++ b/tests/auto/declarative_core/tst_categorymodel.qml @@ -221,7 +221,7 @@ TestCase { //iteration. //try updating with an uninitialized plugin instance. - testModel.plugin = uninitializedPlugin; + testModel.plugin = uninitializedPlugin; // uninitialized does not trigger update on setPlugin testModel.update(); tryCompare(statusChangedSpy, "count", 2); compare(testModel.status, CategoryModel.Error); @@ -229,8 +229,9 @@ TestCase { //try searching with plugin a instance //that has been provided a non-existent name + tryCompare(statusChangedSpy, "count", 0); testModel.plugin = nonExistantPlugin; - testModel.update(); +// testModel.update(); //QTBUG-70254 tryCompare(statusChangedSpy, "count", 2); compare(testModel.status, CategoryModel.Error); } -- cgit v1.2.1 From 27f08fe55608d14368d6cdeb915b7609a1b8b9f2 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 22 Nov 2018 10:34:55 +0100 Subject: winrt: Minor code cleanup - Use nullptr instead of 0 - Use recommended way of including Qt headers Change-Id: I170dbb5aa41a2dd4d10ff99c421da8a037cbe153 Reviewed-by: Alex Blasche --- src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp | 9 +++++---- src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h | 4 ++-- .../position/winrt/qgeopositioninfosourcefactory_winrt.cpp | 6 +++--- src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index 046d862e..b1c1410f 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -36,11 +36,12 @@ #include "qgeopositioninfosource_winrt_p.h" -#include -#include -#include +#include +#include +#include +#include #ifdef Q_OS_WINRT -#include +#include #endif #include diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h b/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h index 9f3a1c7f..5d291fce 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h @@ -51,7 +51,7 @@ #include "qgeopositioninfosource.h" #include "qgeopositioninfo.h" -#include +#include #include #include @@ -76,7 +76,7 @@ class QGeoPositionInfoSourceWinRT : public QGeoPositionInfoSource { Q_OBJECT public: - QGeoPositionInfoSourceWinRT(QObject *parent = 0); + QGeoPositionInfoSourceWinRT(QObject *parent = nullptr); ~QGeoPositionInfoSourceWinRT(); int init(); diff --git a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp index e58744a0..adb63f04 100644 --- a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp @@ -42,7 +42,7 @@ QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryWinRT::positionInfoSource(Q QGeoPositionInfoSourceWinRT *src = new QGeoPositionInfoSourceWinRT(parent); if (src->init() < 0) { delete src; - src = 0; + src = nullptr; } return src; } @@ -50,11 +50,11 @@ QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryWinRT::positionInfoSource(Q QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryWinRT::satelliteInfoSource(QObject *parent) { Q_UNUSED(parent); - return 0; + return nullptr; } QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryWinRT::areaMonitor(QObject *parent) { Q_UNUSED(parent); - return 0; + return nullptr; } diff --git a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h index 46cd3853..d09ddb64 100644 --- a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h +++ b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h @@ -37,8 +37,8 @@ #ifndef QGEOPOSITIONINFOSOURCEFACTORY_WINRT_H #define QGEOPOSITIONINFOSOURCEFACTORY_WINRT_H -#include -#include +#include +#include QT_BEGIN_NAMESPACE -- cgit v1.2.1 From 536668aef188df181cc6986355db195579f44206 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 22 Nov 2018 10:46:52 +0100 Subject: winrt: Fix setting of verticalAccuracy Change-Id: I74ce6e9433eb7ad0f065ea5c554a8c11dd690604 Reviewed-by: Alex Blasche --- src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index b1c1410f..2ce06a8b 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -478,7 +478,7 @@ HRESULT QGeoPositionInfoSourceWinRT::onPositionChanged(IGeolocator *locator, IPo hr = coord->get_AltitudeAccuracy(&altAccuracy); if (SUCCEEDED(hr) && altAccuracy) { double value; - hr = alt->get_Value(&value); + hr = altAccuracy->get_Value(&value); currentInfo.setAttribute(QGeoPositionInfo::VerticalAccuracy, value); } -- cgit v1.2.1 From c83f4565687e4ab3de87248362305d833ca8eea1 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 22 Nov 2018 10:37:27 +0100 Subject: winrt: Replace deprecated functions get_Altitude and the like are marked deprecated and thus should not be used. Use proper replacement functions as advised in Microsoft's documentation. Change-Id: I2166611a3133cadf9fb110242f231d76ca517932 Reviewed-by: Joerg Bornemann --- .../winrt/qgeopositioninfosource_winrt.cpp | 51 +++++++++++++--------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index 2ce06a8b..21e0fddd 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -436,38 +436,49 @@ HRESULT QGeoPositionInfoSourceWinRT::onPositionChanged(IGeolocator *locator, IPo Q_UNUSED(locator); HRESULT hr; - ComPtr pos; - hr = args->get_Position(&pos); + ComPtr position; + hr = args->get_Position(&position); RETURN_HR_IF_FAILED("Could not access position object."); QGeoPositionInfo currentInfo; ComPtr coord; - hr = pos->get_Coordinate(&coord); + hr = position->get_Coordinate(&coord); if (FAILED(hr)) qErrnoWarning(hr, "Could not access coordinate"); - DOUBLE lat; - hr = coord->get_Latitude(&lat); + ComPtr pointCoordinate; + hr = coord.As(&pointCoordinate); if (FAILED(hr)) - qErrnoWarning(hr, "Could not access latitude"); + qErrnoWarning(hr, "Could not cast coordinate."); - DOUBLE lon; - hr = coord->get_Longitude(&lon); + ComPtr point; + hr = pointCoordinate->get_Point(&point); if (FAILED(hr)) - qErrnoWarning(hr, "Could not access longitude"); - - // Depending on data source altitude can - // be identified or not - IReference *alt; - hr = coord->get_Altitude(&alt); - if (SUCCEEDED(hr) && alt) { - double altd; - hr = alt->get_Value(&altd); - currentInfo.setCoordinate(QGeoCoordinate(lat, lon, altd)); - } else { - currentInfo.setCoordinate(QGeoCoordinate(lat, lon)); + qErrnoWarning(hr, "Could not obtain coordinate's point."); + + BasicGeoposition pos; + hr = point->get_Position(&pos); + if (FAILED(hr)) + qErrnoWarning(hr, "Could not obtain point's position."); + + DOUBLE lat = pos.Latitude; + DOUBLE lon = pos.Longitude; + DOUBLE alt = pos.Altitude; + + bool altitudeAvailable = false; + ComPtr shape; + hr = point.As(&shape); + if (SUCCEEDED(hr) && shape) { + AltitudeReferenceSystem altitudeSystem; + hr = shape->get_AltitudeReferenceSystem(&altitudeSystem); + if (SUCCEEDED(hr) && altitudeSystem == AltitudeReferenceSystem_Geoid) + altitudeAvailable = true; } + if (altitudeAvailable) + currentInfo.setCoordinate(QGeoCoordinate(lat, lon, alt)); + else + currentInfo.setCoordinate(QGeoCoordinate(lat, lon)); DOUBLE accuracy; hr = coord->get_Accuracy(&accuracy); -- cgit v1.2.1 From 10e200d710254a30dc5e2d4eb2104f3f2b7f7f0c Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 22 Nov 2018 14:30:23 +0100 Subject: winrt: Make sure that Co(Un)Initialize is called If the QGeoPositionInfoSource is created in a command line app we cannot rely on CoInitialize having been called by the event dispatcher before. Fixes: QTBUG-71194 Change-Id: Id2a8fd22f7b4cf6e5c2629bf7dcd8319b585666e Reviewed-by: Alex Blasche Reviewed-by: Andy Shaw --- src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index 21e0fddd..c41f63bc 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -91,6 +91,7 @@ QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent) : QGeoPositionInfoSource(parent) , d_ptr(new QGeoPositionInfoSourceWinRTPrivate) { + CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); Q_D(QGeoPositionInfoSourceWinRT); d->positionError = QGeoPositionInfoSource::NoError; d->updatesOngoing = false; @@ -98,6 +99,7 @@ QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent) QGeoPositionInfoSourceWinRT::~QGeoPositionInfoSourceWinRT() { + CoUninitialize(); } int QGeoPositionInfoSourceWinRT::init() -- cgit v1.2.1 From 98e28cfc3482cb5a8c8e7f6f288b0d29906ada05 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 22 Nov 2018 15:05:09 +0100 Subject: winrt: Fix namespaced builds Change-Id: Ic9df2c2870184eacc2d1400fc51354ee1da0c288 Reviewed-by: Alex Blasche --- src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp index adb63f04..79b6236b 100644 --- a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp @@ -37,6 +37,8 @@ #include "qgeopositioninfosourcefactory_winrt.h" #include "qgeopositioninfosource_winrt_p.h" +QT_BEGIN_NAMESPACE + QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryWinRT::positionInfoSource(QObject *parent) { QGeoPositionInfoSourceWinRT *src = new QGeoPositionInfoSourceWinRT(parent); @@ -58,3 +60,5 @@ QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryWinRT::areaMonitor(QObject * Q_UNUSED(parent); return nullptr; } + +QT_END_NAMESPACE -- cgit v1.2.1 From 3cf061dc8da4d564de06efa6800749f3eacf47eb Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 23 Nov 2018 09:46:04 +0100 Subject: winrt: Add categorized logging Change-Id: I641690a87dab2527493c3c16ffb476e4121d9ecb Reviewed-by: Alex Blasche --- .../winrt/qgeopositioninfosource_winrt.cpp | 22 ++++++++++++++++++++++ .../winrt/qgeopositioninfosourcefactory_winrt.cpp | 11 ++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index c41f63bc..d995fd79 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -61,6 +61,8 @@ typedef ITypedEventHandler GeoLocatorSta typedef IAsyncOperationCompletedHandler PositionHandler; typedef IAsyncOperationCompletedHandler AccessHandler; +Q_DECLARE_LOGGING_CATEGORY(lcPositioningWinRT) + QT_BEGIN_NAMESPACE #ifndef Q_OS_WINRT @@ -91,6 +93,7 @@ QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent) : QGeoPositionInfoSource(parent) , d_ptr(new QGeoPositionInfoSourceWinRTPrivate) { + qCDebug(lcPositioningWinRT) << __FUNCTION__; CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); Q_D(QGeoPositionInfoSourceWinRT); d->positionError = QGeoPositionInfoSource::NoError; @@ -99,11 +102,13 @@ QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent) QGeoPositionInfoSourceWinRT::~QGeoPositionInfoSourceWinRT() { + qCDebug(lcPositioningWinRT) << __FUNCTION__; CoUninitialize(); } int QGeoPositionInfoSourceWinRT::init() { + qCDebug(lcPositioningWinRT) << __FUNCTION__; Q_D(QGeoPositionInfoSourceWinRT); if (!requestAccess()) { qWarning ("Location access failed."); @@ -154,6 +159,7 @@ int QGeoPositionInfoSourceWinRT::init() QGeoPositionInfo QGeoPositionInfoSourceWinRT::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const { + qCDebug(lcPositioningWinRT) << __FUNCTION__; Q_D(const QGeoPositionInfoSourceWinRT); Q_UNUSED(fromSatellitePositioningMethodsOnly) return d->lastPosition; @@ -170,6 +176,7 @@ QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceWinRT::supporte }); if (FAILED(hr)) return QGeoPositionInfoSource::NoPositioningMethods; + qCDebug(lcPositioningWinRT) << __FUNCTION__ << status; switch (status) { case PositionStatus::PositionStatus_NoData: @@ -183,6 +190,7 @@ QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceWinRT::supporte void QGeoPositionInfoSourceWinRT::setPreferredPositioningMethods(QGeoPositionInfoSource::PositioningMethods methods) { + qCDebug(lcPositioningWinRT) << __FUNCTION__ << methods; Q_D(QGeoPositionInfoSourceWinRT); PositioningMethods previousPreferredPositioningMethods = preferredPositioningMethods(); @@ -210,6 +218,7 @@ void QGeoPositionInfoSourceWinRT::setPreferredPositioningMethods(QGeoPositionInf void QGeoPositionInfoSourceWinRT::setUpdateInterval(int msec) { + qCDebug(lcPositioningWinRT) << __FUNCTION__ << msec; Q_D(QGeoPositionInfoSourceWinRT); // Windows Phone 8.1 and Windows 10 do not support 0 interval #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) @@ -243,6 +252,7 @@ int QGeoPositionInfoSourceWinRT::minimumUpdateInterval() const void QGeoPositionInfoSourceWinRT::startUpdates() { + qCDebug(lcPositioningWinRT) << __FUNCTION__; Q_D(QGeoPositionInfoSourceWinRT); if (d->updatesOngoing) @@ -256,6 +266,7 @@ void QGeoPositionInfoSourceWinRT::startUpdates() void QGeoPositionInfoSourceWinRT::stopUpdates() { + qCDebug(lcPositioningWinRT) << __FUNCTION__; Q_D(QGeoPositionInfoSourceWinRT); stopHandler(); @@ -265,6 +276,7 @@ void QGeoPositionInfoSourceWinRT::stopUpdates() bool QGeoPositionInfoSourceWinRT::startHandler() { + qCDebug(lcPositioningWinRT) << __FUNCTION__; Q_D(QGeoPositionInfoSourceWinRT); // Check if already attached @@ -304,6 +316,7 @@ bool QGeoPositionInfoSourceWinRT::startHandler() void QGeoPositionInfoSourceWinRT::stopHandler() { + qCDebug(lcPositioningWinRT) << __FUNCTION__; Q_D(QGeoPositionInfoSourceWinRT); if (!d->positionToken.value) @@ -317,6 +330,7 @@ void QGeoPositionInfoSourceWinRT::stopHandler() void QGeoPositionInfoSourceWinRT::requestUpdate(int timeout) { + qCDebug(lcPositioningWinRT) << __FUNCTION__; Q_D(QGeoPositionInfoSourceWinRT); if (timeout != 0 && timeout < minimumUpdateInterval()) { @@ -333,6 +347,7 @@ void QGeoPositionInfoSourceWinRT::requestUpdate(int timeout) void QGeoPositionInfoSourceWinRT::virtualPositionUpdate() { + qCDebug(lcPositioningWinRT) << __FUNCTION__; Q_D(QGeoPositionInfoSourceWinRT); QMutexLocker locker(&d->mutex); @@ -370,6 +385,7 @@ void QGeoPositionInfoSourceWinRT::singleUpdateTimeOut() void QGeoPositionInfoSourceWinRT::updateSynchronized(QGeoPositionInfo currentInfo) { + qCDebug(lcPositioningWinRT) << __FUNCTION__ << currentInfo; Q_D(QGeoPositionInfoSourceWinRT); QMutexLocker locker(&d->mutex); @@ -391,11 +407,13 @@ void QGeoPositionInfoSourceWinRT::updateSynchronized(QGeoPositionInfo currentInf QGeoPositionInfoSource::Error QGeoPositionInfoSourceWinRT::error() const { Q_D(const QGeoPositionInfoSourceWinRT); + qCDebug(lcPositioningWinRT) << __FUNCTION__ << d->positionError; return d->positionError; } void QGeoPositionInfoSourceWinRT::setError(QGeoPositionInfoSource::Error positionError) { + qCDebug(lcPositioningWinRT) << __FUNCTION__ << positionError; Q_D(QGeoPositionInfoSourceWinRT); if (positionError == d->positionError) @@ -407,6 +425,7 @@ void QGeoPositionInfoSourceWinRT::setError(QGeoPositionInfoSource::Error positio bool QGeoPositionInfoSourceWinRT::checkNativeState() { Q_D(QGeoPositionInfoSourceWinRT); + qCDebug(lcPositioningWinRT) << __FUNCTION__; PositionStatus status; HRESULT hr = d->locator->get_LocationStatus(&status); @@ -435,6 +454,7 @@ bool QGeoPositionInfoSourceWinRT::checkNativeState() HRESULT QGeoPositionInfoSourceWinRT::onPositionChanged(IGeolocator *locator, IPositionChangedEventArgs *args) { + qCDebug(lcPositioningWinRT) << __FUNCTION__; Q_UNUSED(locator); HRESULT hr; @@ -543,12 +563,14 @@ HRESULT QGeoPositionInfoSourceWinRT::onStatusChanged(IGeolocator*, IStatusChange { PositionStatus st; args->get_Status(&st); + qCDebug(lcPositioningWinRT) << __FUNCTION__ << st; return S_OK; } bool QGeoPositionInfoSourceWinRT::requestAccess() const { #ifdef Q_OS_WINRT + qCDebug(lcPositioningWinRT) << __FUNCTION__; static GeolocationAccessStatus accessStatus = GeolocationAccessStatus_Unspecified; static ComPtr statics; diff --git a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp index 79b6236b..b1ec6fb3 100644 --- a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp @@ -37,26 +37,35 @@ #include "qgeopositioninfosourcefactory_winrt.h" #include "qgeopositioninfosource_winrt_p.h" +#include + +Q_LOGGING_CATEGORY(lcPositioningWinRT, "qt.positioning.winrt") + QT_BEGIN_NAMESPACE QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryWinRT::positionInfoSource(QObject *parent) { + qCDebug(lcPositioningWinRT) << __FUNCTION__; QGeoPositionInfoSourceWinRT *src = new QGeoPositionInfoSourceWinRT(parent); if (src->init() < 0) { + qCDebug(lcPositioningWinRT) << __FUNCTION__ << "Source initialization failed."; delete src; - src = nullptr; + return nullptr; } + qCDebug(lcPositioningWinRT) << __FUNCTION__ << "Created position info source."; return src; } QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryWinRT::satelliteInfoSource(QObject *parent) { + qCDebug(lcPositioningWinRT) << __FUNCTION__; Q_UNUSED(parent); return nullptr; } QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryWinRT::areaMonitor(QObject *parent) { + qCDebug(lcPositioningWinRT) << __FUNCTION__; Q_UNUSED(parent); return nullptr; } -- cgit v1.2.1 From 3c8b439d84a0ef646d49126f2cfdc59f1eccb883 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 23 Nov 2018 09:47:24 +0100 Subject: winrt: Add nativeStatus helper functions Gets rid of duplicated code. Change-Id: I4635b23c5ae431867299eeeafd4bd260f8ba156f Reviewed-by: Alex Blasche --- .../winrt/qgeopositioninfosource_winrt.cpp | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index d995fd79..8a72eb39 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -86,8 +86,24 @@ public: EventRegistrationToken positionToken; QMutex mutex; bool updatesOngoing; + + PositionStatus nativeStatus() const; }; +PositionStatus QGeoPositionInfoSourceWinRTPrivate::nativeStatus() const +{ + qCDebug(lcPositioningWinRT) << __FUNCTION__; + + PositionStatus status; + HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([this, &status]() { + return locator->get_LocationStatus(&status); + }); + if (FAILED(hr)) { + qErrnoWarning(hr, "Could not query status"); + return PositionStatus_NotAvailable; + } + return status; +} QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent) : QGeoPositionInfoSource(parent) @@ -169,13 +185,7 @@ QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceWinRT::supporte { Q_D(const QGeoPositionInfoSourceWinRT); - PositionStatus status; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d, &status]() { - HRESULT hr = d->locator->get_LocationStatus(&status); - return hr; - }); - if (FAILED(hr)) - return QGeoPositionInfoSource::NoPositioningMethods; + PositionStatus status = d->nativeStatus(); qCDebug(lcPositioningWinRT) << __FUNCTION__ << status; switch (status) { @@ -427,13 +437,7 @@ bool QGeoPositionInfoSourceWinRT::checkNativeState() Q_D(QGeoPositionInfoSourceWinRT); qCDebug(lcPositioningWinRT) << __FUNCTION__; - PositionStatus status; - HRESULT hr = d->locator->get_LocationStatus(&status); - if (FAILED(hr)) { - setError(QGeoPositionInfoSource::UnknownSourceError); - qErrnoWarning(hr, "Could not query status"); - return false; - } + PositionStatus status = d->nativeStatus(); bool result = false; switch (status) { -- cgit v1.2.1 From d16a2c0849ad7280893f3fe5259fd6fbd974ce72 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 23 Nov 2018 09:48:11 +0100 Subject: winrt: Small code cleanup Windows 8.1 is no longer supported Change-Id: I00d103057a63abbcbc3ad3baa8ef93b35e07e819 Reviewed-by: Alex Blasche --- src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index 8a72eb39..1a2554b0 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -208,7 +208,7 @@ void QGeoPositionInfoSourceWinRT::setPreferredPositioningMethods(QGeoPositionInf if (previousPreferredPositioningMethods == preferredPositioningMethods()) return; - bool needsRestart = d->positionToken.value != 0; + const bool needsRestart = d->positionToken.value != 0; if (needsRestart) stopHandler(); @@ -230,11 +230,8 @@ void QGeoPositionInfoSourceWinRT::setUpdateInterval(int msec) { qCDebug(lcPositioningWinRT) << __FUNCTION__ << msec; Q_D(QGeoPositionInfoSourceWinRT); - // Windows Phone 8.1 and Windows 10 do not support 0 interval -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) if (msec == 0) msec = minimumUpdateInterval(); -#endif // If msec is 0 we send updates as data becomes available, otherwise we force msec to be equal // to or larger than the minimum update interval. -- cgit v1.2.1 From 4f6e1d3d5542749e265c0d3ed0953ca66174ce49 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 23 Nov 2018 09:49:07 +0100 Subject: winrt: Check availability in requestAccess on desktop builds For some reason the native status is always Disabled for desktop builds (even though the location service is running). So with desktop builds we have to use requestAccess to gain information about the state of the location service. As the functionality is async the important parts of QWinRTFunctions are shadowed locally. Change-Id: I575ee0b161de734c29453a7a07350bc8d09720e8 Reviewed-by: Andre de la Rocha Reviewed-by: Miguel Costa Reviewed-by: Alex Blasche --- .../winrt/qgeopositioninfosource_winrt.cpp | 44 +++++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index 1a2554b0..025a2c9c 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -73,7 +73,36 @@ HRESULT runOnXamlThread(const std::function &delegate, bool waitForR return delegate(); } } -#endif + +static inline HRESULT await(const ComPtr> &asyncOp, + GeolocationAccessStatus *result) +{ + ComPtr asyncInfo; + HRESULT hr = asyncOp.As(&asyncInfo); + if (FAILED(hr)) + return hr; + + AsyncStatus status; + while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) + QThread::yieldCurrentThread(); + + if (FAILED(hr) || status != AsyncStatus::Completed) { + HRESULT ec; + hr = asyncInfo->get_ErrorCode(&ec); + if (FAILED(hr)) + return hr; + hr = asyncInfo->Close(); + if (FAILED(hr)) + return hr; + return ec; + } + + if (FAILED(hr)) + return hr; + + return asyncOp->GetResults(result); +} +#endif // !Q_OS_WINRT class QGeoPositionInfoSourceWinRTPrivate { public: @@ -92,6 +121,7 @@ public: PositionStatus QGeoPositionInfoSourceWinRTPrivate::nativeStatus() const { +#ifdef Q_OS_WINRT qCDebug(lcPositioningWinRT) << __FUNCTION__; PositionStatus status; @@ -103,8 +133,12 @@ PositionStatus QGeoPositionInfoSourceWinRTPrivate::nativeStatus() const return PositionStatus_NotAvailable; } return status; +#else + return PositionStatus_Ready; +#endif } + QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent) : QGeoPositionInfoSource(parent) , d_ptr(new QGeoPositionInfoSourceWinRTPrivate) @@ -570,7 +604,6 @@ HRESULT QGeoPositionInfoSourceWinRT::onStatusChanged(IGeolocator*, IStatusChange bool QGeoPositionInfoSourceWinRT::requestAccess() const { -#ifdef Q_OS_WINRT qCDebug(lcPositioningWinRT) << __FUNCTION__; static GeolocationAccessStatus accessStatus = GeolocationAccessStatus_Unspecified; static ComPtr statics; @@ -594,11 +627,12 @@ bool QGeoPositionInfoSourceWinRT::requestAccess() const Q_ASSERT_SUCCEEDED(hr); // We cannot wait inside the XamlThread as that would deadlock +#ifdef Q_OS_WINRT QWinRTFunctions::await(op, &accessStatus); +#else + await(op, &accessStatus); +#endif return accessStatus == GeolocationAccessStatus_Allowed; -#else // Q_OS_WINRT - return true; -#endif // Q_OS_WINRT } QT_END_NAMESPACE -- cgit v1.2.1 From 0b242a11b1193b74a2ab979c29e28553e47cc78e Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 26 Nov 2018 13:12:00 +0100 Subject: winrt: Remove unneeded status change callback We do not use the native callback's result but Windows' backend will complain if we try to set some of GeoLocator's properties while we are registered for status changes. By removing the callback registration we get rid of these warnings. Change-Id: Ic3829ee438c708fb4411ba94ba1202bb427e8815 Reviewed-by: Andre de la Rocha Reviewed-by: Miguel Costa --- .../position/winrt/qgeopositioninfosource_winrt.cpp | 14 -------------- .../position/winrt/qgeopositioninfosource_winrt_p.h | 4 ---- 2 files changed, 18 deletions(-) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index 025a2c9c..9616b1d8 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -57,7 +57,6 @@ using namespace ABI::Windows::Foundation; using namespace ABI::Windows::Foundation::Collections; typedef ITypedEventHandler GeoLocatorPositionHandler; -typedef ITypedEventHandler GeoLocatorStatusHandler; typedef IAsyncOperationCompletedHandler PositionHandler; typedef IAsyncOperationCompletedHandler AccessHandler; @@ -169,11 +168,6 @@ int QGeoPositionInfoSourceWinRT::init() &d->locator); RETURN_HR_IF_FAILED("Could not initialize native location services."); - hr = d->locator->add_StatusChanged(Callback(this, - &QGeoPositionInfoSourceWinRT::onStatusChanged).Get(), - &d->statusToken); - RETURN_HR_IF_FAILED("Could not add status callback."); - hr = d->locator->put_ReportInterval(1000); RETURN_HR_IF_FAILED("Could not initialize report interval."); @@ -594,14 +588,6 @@ HRESULT QGeoPositionInfoSourceWinRT::onPositionChanged(IGeolocator *locator, IPo return S_OK; } -HRESULT QGeoPositionInfoSourceWinRT::onStatusChanged(IGeolocator*, IStatusChangedEventArgs *args) -{ - PositionStatus st; - args->get_Status(&st); - qCDebug(lcPositioningWinRT) << __FUNCTION__ << st; - return S_OK; -} - bool QGeoPositionInfoSourceWinRT::requestAccess() const { qCDebug(lcPositioningWinRT) << __FUNCTION__; diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h b/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h index 5d291fce..4319ccae 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h @@ -62,7 +62,6 @@ namespace ABI { namespace Geolocation{ struct IGeolocator; struct IPositionChangedEventArgs; - struct IStatusChangedEventArgs; } } } @@ -92,9 +91,6 @@ public: HRESULT onPositionChanged(ABI::Windows::Devices::Geolocation::IGeolocator *locator, ABI::Windows::Devices::Geolocation::IPositionChangedEventArgs *args); - HRESULT onStatusChanged(ABI::Windows::Devices::Geolocation::IGeolocator*, - ABI::Windows::Devices::Geolocation::IStatusChangedEventArgs *args); - bool requestAccess() const; Q_SIGNALS: void nativePositionUpdate(const QGeoPositionInfo); -- cgit v1.2.1 From 25493cbb07f8cbc6c6d12cfc575a71875be06692 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 26 Nov 2018 13:14:29 +0100 Subject: winrt: Restart location handler on setUpdateInterval if necessary Windows' backend will complain if we try to set the report interval while being subscribed to position changes so we have to remove this registration and redo it when the new interval is in effect. Change-Id: I5b3f23a7b6e530dd0a3f673e2b8ce6f5102b7eb1 Reviewed-by: Andre de la Rocha Reviewed-by: Miguel Costa Reviewed-by: Alex Blasche --- src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index 9616b1d8..fa537af7 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -266,6 +266,11 @@ void QGeoPositionInfoSourceWinRT::setUpdateInterval(int msec) if (msec != 0 && msec < minimumUpdateInterval()) msec = minimumUpdateInterval(); + const bool needsRestart = d->positionToken.value != 0; + + if (needsRestart) + stopHandler(); + HRESULT hr = d->locator->put_ReportInterval(msec); if (FAILED(hr)) { setError(QGeoPositionInfoSource::UnknownSourceError); @@ -276,6 +281,9 @@ void QGeoPositionInfoSourceWinRT::setUpdateInterval(int msec) d->periodicTimer.setInterval(qMax(msec, minimumUpdateInterval())); QGeoPositionInfoSource::setUpdateInterval(msec); + + if (needsRestart) + startHandler(); } int QGeoPositionInfoSourceWinRT::minimumUpdateInterval() const -- cgit v1.2.1 From 9307404d2dcb0b53d0dfcad6c28677cc2aba4a12 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 26 Nov 2018 15:04:05 +0100 Subject: winrt: Implement minimumUpdateInterval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to MSDN GeoLocator's default ReportInterval is 1 second or as frequent as the hardware can support – whichever is shorter. By using that functionality we can support minimumUpdateInterval "properly". Change-Id: Id54197babeec04c8fc0a309930b192e36d9138f8 Reviewed-by: Miguel Costa --- .../winrt/qgeopositioninfosource_winrt.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index fa537af7..139a6b3d 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -114,6 +114,7 @@ public: EventRegistrationToken positionToken; QMutex mutex; bool updatesOngoing; + int minimumUpdateInterval; PositionStatus nativeStatus() const; }; @@ -168,8 +169,11 @@ int QGeoPositionInfoSourceWinRT::init() &d->locator); RETURN_HR_IF_FAILED("Could not initialize native location services."); - hr = d->locator->put_ReportInterval(1000); - RETURN_HR_IF_FAILED("Could not initialize report interval."); + UINT32 interval; + hr = d->locator->get_ReportInterval(&interval); + RETURN_HR_IF_FAILED("Could not retrieve report interval."); + d->minimumUpdateInterval = static_cast(interval); + setUpdateInterval(d->minimumUpdateInterval); return hr; }); @@ -189,7 +193,6 @@ int QGeoPositionInfoSourceWinRT::init() d->positionToken.value = 0; d->periodicTimer.setSingleShot(true); - d->periodicTimer.setInterval(minimumUpdateInterval()); connect(&d->periodicTimer, &QTimer::timeout, this, &QGeoPositionInfoSourceWinRT::virtualPositionUpdate); d->singleUpdateTimer.setSingleShot(true); @@ -258,11 +261,9 @@ void QGeoPositionInfoSourceWinRT::setUpdateInterval(int msec) { qCDebug(lcPositioningWinRT) << __FUNCTION__ << msec; Q_D(QGeoPositionInfoSourceWinRT); - if (msec == 0) - msec = minimumUpdateInterval(); - - // If msec is 0 we send updates as data becomes available, otherwise we force msec to be equal - // to or larger than the minimum update interval. + // minimumUpdateInterval is initialized to the lowest possible update interval in init(). + // Passing 0 will cause an error on Windows 10. + // See https://docs.microsoft.com/en-us/uwp/api/windows.devices.geolocation.geolocator.reportinterval if (msec != 0 && msec < minimumUpdateInterval()) msec = minimumUpdateInterval(); @@ -271,7 +272,7 @@ void QGeoPositionInfoSourceWinRT::setUpdateInterval(int msec) if (needsRestart) stopHandler(); - HRESULT hr = d->locator->put_ReportInterval(msec); + HRESULT hr = d->locator->put_ReportInterval(static_cast(msec)); if (FAILED(hr)) { setError(QGeoPositionInfoSource::UnknownSourceError); qErrnoWarning(hr, "Failed to set update interval"); @@ -288,9 +289,8 @@ void QGeoPositionInfoSourceWinRT::setUpdateInterval(int msec) int QGeoPositionInfoSourceWinRT::minimumUpdateInterval() const { - // We use one second to reduce potential timer events - // in case the platform itself stops reporting - return 1000; + Q_D(const QGeoPositionInfoSourceWinRT); + return d->minimumUpdateInterval; } void QGeoPositionInfoSourceWinRT::startUpdates() -- cgit v1.2.1 From be0658bfdb37de213f6b54837706aabc2d088d62 Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Sun, 11 Nov 2018 14:16:49 +0100 Subject: Make tiled renderer and QGeoProjectionWebMercator debuggable This patch introduces a new macro, QT_LOCATION_DEBUG, that, when fed via qmake command line, changes the scope of some members, adds some extra members and some extra data dumping into these members. In this way external code can inspect the state of the renderer in order to debug it. The patch also moves a few classes into separate files, as well as privately exporting them. Change-Id: I32a042863f78dcd10f94b0b7fe8b90f3fc486891 Reviewed-by: Paolo Angelelli --- .qmake.conf | 5 + .../qdeclarativepolylinemapitem.cpp | 10 +- .../qdeclarativepolylinemapitem_p.h | 11 +- src/location/maps/maps.pri | 3 + src/location/maps/qgeocameratiles.cpp | 90 ++-------- src/location/maps/qgeocameratiles_p.h | 2 + src/location/maps/qgeocameratiles_p_p.h | 152 ++++++++++++++++ src/location/maps/qgeomap_p_p.h | 4 + src/location/maps/qgeoprojection.cpp | 14 +- src/location/maps/qgeoprojection_p.h | 8 +- src/location/maps/qgeotiledmap_p_p.h | 4 + src/location/maps/qgeotiledmapscene.cpp | 154 ++++------------ src/location/maps/qgeotiledmapscene_p_p.h | 193 +++++++++++++++++++++ 13 files changed, 444 insertions(+), 206 deletions(-) create mode 100644 src/location/maps/qgeocameratiles_p_p.h create mode 100644 src/location/maps/qgeotiledmapscene_p_p.h diff --git a/.qmake.conf b/.qmake.conf index 3566a973..0815e3b5 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,3 +2,8 @@ load(qt_build_config) CONFIG += warning_clean MODULE_VERSION = 5.12.0 + +# Adds a way to debug location. The define is needed for multiple subprojects as they +# include the essential headers. +# Alternatively, the define can be passed directly to qmake +# DEFINES+=QT_LOCATION_DEBUG diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp index aeb7b718..2fb3098d 100644 --- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp @@ -398,6 +398,10 @@ QList > QGeoMapPolylineGeometry::clipPath(const QGeoMap & wrappedPath.append(wrappedProjection); } +#ifdef QT_LOCATION_DEBUG + m_wrappedPath = wrappedPath; +#endif + // 2) QList > clippedPaths; const QList &visibleRegion = p.projectableGeometry(); @@ -428,6 +432,10 @@ QList > QGeoMapPolylineGeometry::clipPath(const QGeoMap & clippedPaths.append(wrappedPath); } +#ifdef QT_LOCATION_DEBUG + m_clippedPaths = clippedPaths; +#endif + return clippedPaths; } @@ -441,14 +449,12 @@ void QGeoMapPolylineGeometry::pathToScreen(const QGeoMap &map, double minY = qInf(); double maxX = -qInf(); double maxY = -qInf(); - srcOrigin_ = p.mapProjectionToGeo(p.unwrapMapProjection(leftBoundWrapped)); QDoubleVector2D origin = p.wrappedMapProjectionToItemPosition(leftBoundWrapped); for (const QList &path: clippedPaths) { QDoubleVector2D lastAddedPoint; for (int i = 0; i < path.size(); ++i) { QDoubleVector2D point = p.wrappedMapProjectionToItemPosition(path.at(i)); - point = point - origin; // (0,0) if point == geoLeftBound_ minX = qMin(point.x(), minX); diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h index 392841dd..1105bb13 100644 --- a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h +++ b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h @@ -48,6 +48,7 @@ // We mean it. // +#include #include #include @@ -110,10 +111,15 @@ public: const QList > &clippedPaths, const QDoubleVector2D &leftBoundWrapped); -private: +public: QVector srcPoints_; QVector srcPointTypes_; +#ifdef QT_LOCATION_DEBUG + QList m_wrappedPath; + QList> m_clippedPaths; +#endif + friend class QDeclarativeCircleMapItem; friend class QDeclarativePolygonMapItem; friend class QDeclarativeRectangleMapItem; @@ -171,6 +177,9 @@ private: void regenerateCache(); void updateCache(); +#ifdef QT_LOCATION_DEBUG +public: +#endif QGeoPath geopath_; QList geopathProjected_; QDeclarativeMapLineProperties line_; diff --git a/src/location/maps/maps.pri b/src/location/maps/maps.pri index b5be4601..68e80442 100644 --- a/src/location/maps/maps.pri +++ b/src/location/maps/maps.pri @@ -62,6 +62,8 @@ PRIVATE_HEADERS += \ maps/qgeoprojection_p.h \ maps/qnavigationmanagerengine_p.h \ maps/qnavigationmanager_p.h \ + maps/qgeocameratiles_p_p.h \ + maps/qgeotiledmapscene_p_p.h \ maps/qcache3q_p.h SOURCES += \ @@ -100,3 +102,4 @@ SOURCES += \ maps/qnavigationmanagerengine.cpp \ maps/qnavigationmanager.cpp \ maps/qgeoprojection.cpp + diff --git a/src/location/maps/qgeocameratiles.cpp b/src/location/maps/qgeocameratiles.cpp index b7eac306..3a2732b2 100644 --- a/src/location/maps/qgeocameratiles.cpp +++ b/src/location/maps/qgeocameratiles.cpp @@ -34,6 +34,7 @@ ** ****************************************************************************/ #include "qgeocameratiles_p.h" +#include "qgeocameratiles_p_p.h" #include "qgeocameradata_p.h" #include "qgeotilespec_p.h" #include "qgeomaptype_p.h" @@ -63,76 +64,6 @@ static QDoubleVector3D toDoubleVector3D(const QVector3D& in) QT_BEGIN_NAMESPACE -struct Frustum -{ - QDoubleVector3D apex; - QDoubleVector3D topLeftNear; - QDoubleVector3D topLeftFar; - QDoubleVector3D topRightNear; - QDoubleVector3D topRightFar; - QDoubleVector3D bottomLeftNear; - QDoubleVector3D bottomLeftFar; - QDoubleVector3D bottomRightNear; - QDoubleVector3D bottomRightFar; -}; - -typedef QVector PolygonVector; - -class QGeoCameraTilesPrivate -{ -public: - QGeoCameraTilesPrivate(); - ~QGeoCameraTilesPrivate(); - - QString m_pluginString; - QGeoMapType m_mapType; - int m_mapVersion; - QGeoCameraData m_camera; - QSize m_screenSize; - QRectF m_visibleArea; - int m_tileSize; - QSet m_tiles; - - int m_intZoomLevel; - int m_sideLength; - - bool m_dirtyGeometry; - bool m_dirtyMetadata; - - double m_viewExpansion; - void updateMetadata(); - void updateGeometry(); - - Frustum createFrustum(double viewExpansion) const; - - struct ClippedFootprint - { - ClippedFootprint(const PolygonVector &left_, const PolygonVector &mid_, const PolygonVector &right_) - : left(left_), mid(mid_), right(right_) - {} - PolygonVector left; - PolygonVector mid; - PolygonVector right; - }; - - PolygonVector frustumFootprint(const Frustum &frustum) const; - - QPair splitPolygonAtAxisValue(const PolygonVector &polygon, int axis, double value) const; - ClippedFootprint clipFootprintToMap(const PolygonVector &footprint) const; - - QList > tileIntersections(double p1, int t1, double p2, int t2) const; - QSet tilesFromPolygon(const PolygonVector &polygon) const; - - struct TileMap - { - TileMap(); - - void add(int tileX, int tileY); - - QMap > data; - }; -}; - QGeoCameraTiles::QGeoCameraTiles() : d_ptr(new QGeoCameraTilesPrivate()) {} @@ -277,12 +208,22 @@ void QGeoCameraTilesPrivate::updateGeometry() // Find the frustum from the camera / screen / viewport information // The larger frustum when stationary is a form of prefetching Frustum f = createFrustum(m_viewExpansion); +#ifdef QT_LOCATION_DEBUG + m_frustum = f; +#endif // Find the polygon where the frustum intersects the plane of the map PolygonVector footprint = frustumFootprint(f); +#ifdef QT_LOCATION_DEBUG + m_frustumFootprint = footprint; +#endif // Clip the polygon to the map, split it up if it cross the dateline ClippedFootprint polygons = clipFootprintToMap(footprint); +#ifdef QT_LOCATION_DEBUG + m_clippedFootprint = polygons; +#endif + if (!polygons.left.isEmpty()) { QSet tilesLeft = tilesFromPolygon(polygons.left); @@ -306,6 +247,10 @@ Frustum QGeoCameraTilesPrivate::createFrustum(double viewExpansion) const if (m_camera.fieldOfView() != 90.0) //aperture(90 / 2) = 1 apertureSize = tan(QLocationUtils::radians(m_camera.fieldOfView()) * 0.5); QDoubleVector3D center = m_sideLength * QWebMercator::coordToMercator(m_camera.center()); +#ifdef QT_LOCATION_DEBUG + m_createFrustum_center = center; +#endif + double f = m_screenSize.height(); @@ -335,7 +280,7 @@ Frustum QGeoCameraTilesPrivate::createFrustum(double viewExpansion) const side = QDoubleVector3D::normal(view, QDoubleVector3D(0.0, 1.0, 0.0)); up = QDoubleVector3D::normal(view, side2); - double nearPlane = 1 / (4.0 * m_tileSize ); + double nearPlane = 1.0 / 32.0; // The denominator used to be (4.0 * m_tileSize ), which produces an extremely narrow and tiny near plane. // farPlane plays a role on how much gets clipped when the map gets tilted. It used to be altitude + 1.0 // The value of 8.0 has been chosen as an acceptable compromise. // TODO: use m_camera.clipDistance(); when this will be introduced @@ -367,6 +312,9 @@ Frustum QGeoCameraTilesPrivate::createFrustum(double viewExpansion) const Frustum frustum; frustum.apex = eye; +#ifdef QT_LOCATION_DEBUG + m_createFrustum_eye = eye; +#endif QRectF va = m_visibleArea; if (va.isNull()) diff --git a/src/location/maps/qgeocameratiles_p.h b/src/location/maps/qgeocameratiles_p.h index f95db44d..4b6f3234 100644 --- a/src/location/maps/qgeocameratiles_p.h +++ b/src/location/maps/qgeocameratiles_p.h @@ -79,6 +79,8 @@ public: protected: QScopedPointer d_ptr; + + friend class QGeoCameraTilesPrivate; Q_DISABLE_COPY(QGeoCameraTiles) }; diff --git a/src/location/maps/qgeocameratiles_p_p.h b/src/location/maps/qgeocameratiles_p_p.h new file mode 100644 index 00000000..846d95f2 --- /dev/null +++ b/src/location/maps/qgeocameratiles_p_p.h @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QGEOCAMERATILES_P_P_H +#define QGEOCAMERATILES_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qgeocameratiles_p.h" +#include +#include +#include +#include "qgeomaptype_p.h" +#include "qgeocameradata_p.h" +#include "qgeotilespec_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +struct Q_LOCATION_PRIVATE_EXPORT Frustum +{ + QDoubleVector3D apex; + QDoubleVector3D topLeftNear; + QDoubleVector3D topLeftFar; + QDoubleVector3D topRightNear; + QDoubleVector3D topRightFar; + QDoubleVector3D bottomLeftNear; + QDoubleVector3D bottomLeftFar; + QDoubleVector3D bottomRightNear; + QDoubleVector3D bottomRightFar; +}; + +typedef QVector PolygonVector; + +class Q_LOCATION_PRIVATE_EXPORT QGeoCameraTilesPrivate +{ +public: + struct ClippedFootprint + { + ClippedFootprint() + {} + ClippedFootprint(const PolygonVector &left_, const PolygonVector &mid_, const PolygonVector &right_) + : left(left_), mid(mid_), right(right_) + {} + PolygonVector left; + PolygonVector mid; + PolygonVector right; + }; + + struct TileMap + { + TileMap(); + + void add(int tileX, int tileY); + + QMap > data; + }; + + QGeoCameraTilesPrivate(); + ~QGeoCameraTilesPrivate(); + + + void updateMetadata(); + void updateGeometry(); + + Frustum createFrustum(double viewExpansion) const; + PolygonVector frustumFootprint(const Frustum &frustum) const; + + QPair splitPolygonAtAxisValue(const PolygonVector &polygon, int axis, double value) const; + ClippedFootprint clipFootprintToMap(const PolygonVector &footprint) const; + + QList > tileIntersections(double p1, int t1, double p2, int t2) const; + QSet tilesFromPolygon(const PolygonVector &polygon) const; + + static QGeoCameraTilesPrivate *get(QGeoCameraTiles *o) { + return o->d_ptr.data(); + } + +public: + QString m_pluginString; + QGeoMapType m_mapType; + int m_mapVersion; + QGeoCameraData m_camera; + QSize m_screenSize; + QRectF m_visibleArea; + int m_tileSize; + QSet m_tiles; + + int m_intZoomLevel; + int m_sideLength; + bool m_dirtyGeometry; + bool m_dirtyMetadata; + double m_viewExpansion; + +#ifdef QT_LOCATION_DEBUG + // updateGeometry + ClippedFootprint m_clippedFootprint; + PolygonVector m_frustumFootprint; + Frustum m_frustum; + + // createFrustum + mutable QDoubleVector3D m_createFrustum_center; + mutable QDoubleVector3D m_createFrustum_eye; +#endif +}; + +QT_END_NAMESPACE + +#endif // QGEOCAMERATILES_P_P_H diff --git a/src/location/maps/qgeomap_p_p.h b/src/location/maps/qgeomap_p_p.h index 7bda316d..331697b2 100644 --- a/src/location/maps/qgeomap_p_p.h +++ b/src/location/maps/qgeomap_p_p.h @@ -110,7 +110,11 @@ protected: QRectF clampVisibleArea(const QRectF &visibleArea) const; +#ifdef QT_LOCATION_DEBUG +public: +#else protected: +#endif QSize m_viewportSize; QGeoProjection *m_geoProjection; QPointer m_engine; diff --git a/src/location/maps/qgeoprojection.cpp b/src/location/maps/qgeoprojection.cpp index 7961ec70..0fdb5f0b 100644 --- a/src/location/maps/qgeoprojection.cpp +++ b/src/location/maps/qgeoprojection.cpp @@ -164,7 +164,7 @@ QGeoProjectionWebMercator::QGeoProjectionWebMercator() m_viewportHeight(1), m_1_viewportWidth(0), m_1_viewportHeight(0), - m_sideLength(256), + m_sideLengthPixels(256), m_aperture(0.0), m_nearPlane(0.0), m_farPlane(0.0), @@ -389,7 +389,7 @@ QMatrix4x4 QGeoProjectionWebMercator::quickItemTransformation(const QGeoCoordina const QDoubleVector2D anchorMercator = anchorScaled / mapWidth(); const QDoubleVector2D coordAnchored = coordWrapped - anchorMercator; - const QDoubleVector2D coordAnchoredScaled = coordAnchored * m_sideLength; + const QDoubleVector2D coordAnchoredScaled = coordAnchored * m_sideLengthPixels; QDoubleMatrix4x4 matTranslateScale; matTranslateScale.translate(coordAnchoredScaled.x(), coordAnchoredScaled.y(), 0.0); @@ -416,7 +416,7 @@ bool QGeoProjectionWebMercator::isProjectable(const QDoubleVector2D &wrappedProj if (m_cameraData.tilt() == 0.0) return true; - QDoubleVector3D pos = wrappedProjection * m_sideLength; + QDoubleVector3D pos = wrappedProjection * m_sideLengthPixels; // use m_centerNearPlane in order to add an offset to m_eye. QDoubleVector3D p = m_centerNearPlane - pos; double dot = QDoubleVector3D::dotProduct(p , m_viewNormalized); @@ -491,7 +491,7 @@ QDoubleVector2D QGeoProjectionWebMercator::viewportToWrappedMapProjection(const QDoubleVector3D ray = m_eye - p; ray.normalize(); - return (xyPlane.lineIntersection(m_eye, ray, s) / m_sideLength).toVector2D(); + return (xyPlane.lineIntersection(m_eye, ray, s) / m_sideLengthPixels).toVector2D(); } /* @@ -552,8 +552,8 @@ void QGeoProjectionWebMercator::setupCamera() m_cameraCenterYMercator = m_centerMercator.y(); int intZoomLevel = static_cast(std::floor(m_cameraData.zoomLevel())); - m_sideLength = (1 << intZoomLevel) * defaultTileSize; - m_center = m_centerMercator * m_sideLength; + m_sideLengthPixels = (1 << intZoomLevel) * defaultTileSize; + m_center = m_centerMercator * m_sideLengthPixels; //aperture(90 / 2) = 1 m_aperture = tan(QLocationUtils::radians(m_cameraData.fieldOfView()) * 0.5); @@ -658,7 +658,7 @@ void QGeoProjectionWebMercator::setupCamera() m_transformation = matScreenTransformation * projectionMatrix * cameraMatrix; m_quickItemTransformation = m_transformation; - m_transformation.scale(m_sideLength, m_sideLength, 1.0); + m_transformation.scale(m_sideLengthPixels, m_sideLengthPixels, 1.0); m_centerNearPlane = m_eye - m_viewNormalized; m_centerNearPlaneMercator = m_eyeMercator - m_viewNormalized * m_nearPlaneMercator; diff --git a/src/location/maps/qgeoprojection_p.h b/src/location/maps/qgeoprojection_p.h index e33ae880..2e1af8c5 100644 --- a/src/location/maps/qgeoprojection_p.h +++ b/src/location/maps/qgeoprojection_p.h @@ -195,7 +195,11 @@ public: QDoubleVector3D m_normal; }; -private: +#ifdef QT_LOCATION_DEBUG +public: +#else +protected: +#endif QGeoCameraData m_cameraData; double m_mapEdgeSize; double m_minimumZoom; @@ -218,7 +222,7 @@ private: QDoubleVector3D m_viewNormalized; QDoubleVector3D m_side; QDoubleVector3D m_centerNearPlane; - double m_sideLength; // map edge size at integer zoom level + double m_sideLengthPixels; // map edge size at integer zoom level double m_aperture; double m_nearPlane; double m_farPlane; diff --git a/src/location/maps/qgeotiledmap_p_p.h b/src/location/maps/qgeotiledmap_p_p.h index 0ba349ca..80f658e0 100644 --- a/src/location/maps/qgeotiledmap_p_p.h +++ b/src/location/maps/qgeotiledmap_p_p.h @@ -94,7 +94,11 @@ protected: void setVisibleArea(const QRectF &visibleArea) override; QRectF visibleArea() const override; +#ifdef QT_LOCATION_DEBUG +public: +#else protected: +#endif QAbstractGeoTileCache *m_cache; QGeoCameraTiles *m_visibleTiles; QGeoCameraTiles *m_prefetchTiles; diff --git a/src/location/maps/qgeotiledmapscene.cpp b/src/location/maps/qgeotiledmapscene.cpp index 4709a48f..074b67c6 100644 --- a/src/location/maps/qgeotiledmapscene.cpp +++ b/src/location/maps/qgeotiledmapscene.cpp @@ -35,15 +35,14 @@ ** ****************************************************************************/ #include "qgeotiledmapscene_p.h" +#include "qgeotiledmapscene_p_p.h" #include "qgeocameradata_p.h" #include "qabstractgeotilecache_p.h" #include "qgeotilespec_p.h" #include #include #include -#include #include -#include #include #include #include @@ -57,61 +56,6 @@ static QVector3D toVector3D(const QDoubleVector3D& in) QT_BEGIN_NAMESPACE -class QGeoTiledMapScenePrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QGeoTiledMapScene) -public: - QGeoTiledMapScenePrivate(); - ~QGeoTiledMapScenePrivate(); - - QSize m_screenSize; // in pixels - int m_tileSize; // the pixel resolution for each tile - QGeoCameraData m_cameraData; - QRectF m_visibleArea; - QSet m_visibleTiles; - - QDoubleVector3D m_cameraUp; - QDoubleVector3D m_cameraEye; - QDoubleVector3D m_cameraCenter; - QMatrix4x4 m_projectionMatrix; - - // scales up the tile geometry and the camera altitude, resulting in no visible effect - // other than to control the accuracy of the render by keeping the values in a sensible range - double m_scaleFactor; - - // rounded down, positive zoom is zooming in, corresponding to reduced altitude - int m_intZoomLevel; - - // mercatorToGrid transform - // the number of tiles in each direction for the whole map (earth) at the current zoom level. - // it is 1< > m_textures; - QVector m_updatedTextures; - - // tilesToGrid transform - int m_minTileX; // the minimum tile index, i.e. 0 to sideLength which is 1<< zoomLevel - int m_minTileY; - int m_maxTileX; - int m_maxTileY; - int m_tileXWrapsBelow; // the wrap point as a tile index - - bool m_linearScaling; - - bool m_dropTextures; - - void addTile(const QGeoTileSpec &spec, QSharedPointer texture); - - void setVisibleTiles(const QSet &visibleTiles); - void removeTiles(const QSet &oldTiles); - bool buildGeometry(const QGeoTileSpec &spec, QSGImageNode *imageNode, bool &overzooming); - void updateTileBounds(const QSet &tiles); - void setupCamera(); - inline bool isTiltedOrRotated() { return (m_cameraData.tilt() > 0.0) || (m_cameraData.bearing() > 0.0); } -}; - QGeoTiledMapScene::QGeoTiledMapScene(QObject *parent) : QObject(*new QGeoTiledMapScenePrivate(),parent) { @@ -201,7 +145,11 @@ void QGeoTiledMapScene::clearTexturedTiles() QGeoTiledMapScenePrivate::QGeoTiledMapScenePrivate() : QObjectPrivate(), m_tileSize(0), +#ifdef QT_LOCATION_DEBUG + m_scaleFactor(1.0), +#else m_scaleFactor(10.0), +#endif m_intZoomLevel(0), m_sideLength(0), m_minTileX(-1), @@ -503,71 +451,6 @@ void QGeoTiledMapScenePrivate::setupCamera() nearPlane, farPlane); } -class QGeoTiledMapTileContainerNode : public QSGTransformNode -{ -public: - void addChild(const QGeoTileSpec &spec, QSGImageNode *node) - { - tiles.insert(spec, node); - appendChildNode(node); - } - QHash tiles; -}; - -class QGeoTiledMapRootNode : public QSGClipNode -{ -public: - QGeoTiledMapRootNode() - : isTextureLinear(false) - , geometry(QSGGeometry::defaultAttributes_Point2D(), 4) - , root(new QSGTransformNode()) - , tiles(new QGeoTiledMapTileContainerNode()) - , wrapLeft(new QGeoTiledMapTileContainerNode()) - , wrapRight(new QGeoTiledMapTileContainerNode()) - { - setIsRectangular(true); - setGeometry(&geometry); - root->appendChildNode(tiles); - root->appendChildNode(wrapLeft); - root->appendChildNode(wrapRight); - appendChildNode(root); - } - - ~QGeoTiledMapRootNode() - { - qDeleteAll(textures); - } - - void setClipRect(const QRect &rect) - { - if (rect != clipRect) { - QSGGeometry::updateRectGeometry(&geometry, rect); - QSGClipNode::setClipRect(rect); - clipRect = rect; - markDirty(DirtyGeometry); - } - } - - void updateTiles(QGeoTiledMapTileContainerNode *root, - QGeoTiledMapScenePrivate *d, - double camAdjust, - QQuickWindow *window, - bool ogl); - - bool isTextureLinear; - - QSGGeometry geometry; - QRect clipRect; - - QSGTransformNode *root; - - QGeoTiledMapTileContainerNode *tiles; // The majority of the tiles - QGeoTiledMapTileContainerNode *wrapLeft; // When zoomed out, the tiles that wrap around on the left. - QGeoTiledMapTileContainerNode *wrapRight; // When zoomed out, the tiles that wrap around on the right - - QHash textures; -}; - static bool qgeotiledmapscene_isTileInViewport_Straight(const QRectF &tileRect, const QMatrix4x4 &matrix) { const QRectF boundingRect = QRectF(matrix * tileRect.topLeft(), matrix * tileRect.bottomRight()); @@ -621,6 +504,9 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root, bool straight = !d->isTiltedOrRotated(); bool overzooming; qreal pixelRatio = window->effectiveDevicePixelRatio(); +#ifdef QT_LOCATION_DEBUG + QList droppedTiles; +#endif for (QHash::iterator it = root->tiles.begin(); it != root->tiles.end(); ) { QSGImageNode *node = it.value(); @@ -630,6 +516,9 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root, QSGNode::DirtyState dirtyBits = 0; if (!ok) { +#ifdef QT_LOCATION_DEBUG + droppedTiles.append(it.key()); +#endif it = root->tiles.erase(it); delete node; } else { @@ -656,8 +545,12 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root, for (const QGeoTileSpec &s : toAdd) { QGeoTileTexture *tileTexture = d->m_textures.value(s).data(); - if (!tileTexture || tileTexture->image.isNull()) + if (!tileTexture || tileTexture->image.isNull()) { +#ifdef QT_LOCATION_DEBUG + droppedTiles.append(s); +#endif continue; + } QSGImageNode *tileNode = window->createImageNode(); // note: setTexture will update coordinates so do it here, before we buildGeometry tileNode->setTexture(textures.value(s)); @@ -675,9 +568,16 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root, #endif root->addChild(s, tileNode); } else { +#ifdef QT_LOCATION_DEBUG + droppedTiles.append(s); +#endif delete tileNode; } } + +#ifdef QT_LOCATION_DEBUG + m_droppedTiles[camAdjust] = droppedTiles; +#endif } QSGNode *QGeoTiledMapScene::updateSceneGraph(QSGNode *oldNode, QQuickWindow *window) @@ -695,6 +595,11 @@ QSGNode *QGeoTiledMapScene::updateSceneGraph(QSGNode *oldNode, QQuickWindow *win if (!mapRoot) mapRoot = new QGeoTiledMapRootNode(); +#ifdef QT_LOCATION_DEBUG + mapRoot->m_droppedTiles.clear(); + d->m_mapRoot = mapRoot; +#endif + // Setting clip rect to fullscreen, as now the map can never be smaller than the viewport. mapRoot->setClipRect(QRect(0, 0, w, h)); @@ -749,6 +654,9 @@ QSGNode *QGeoTiledMapScene::updateSceneGraph(QSGNode *oldNode, QQuickWindow *win } double sideLength = d->m_scaleFactor * d->m_tileSize * d->m_sideLength; +#ifdef QT_LOCATION_DEBUG + d->m_sideLengthPixel = sideLength; +#endif mapRoot->updateTiles(mapRoot->tiles, d, 0, window, isOpenGL); mapRoot->updateTiles(mapRoot->wrapLeft, d, +sideLength, window, isOpenGL); mapRoot->updateTiles(mapRoot->wrapRight, d, -sideLength, window, isOpenGL); diff --git a/src/location/maps/qgeotiledmapscene_p_p.h b/src/location/maps/qgeotiledmapscene_p_p.h new file mode 100644 index 00000000..5d98abd5 --- /dev/null +++ b/src/location/maps/qgeotiledmapscene_p_p.h @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QGEOTILEDMAPSCENE_P_P_H +#define QGEOTILEDMAPSCENE_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qgeotiledmapscene_p.h" +#include +#include +#include +#include +#include +#include "qgeocameradata_p.h" +#include "qgeotilespec_p.h" + +QT_BEGIN_NAMESPACE + +class Q_LOCATION_PRIVATE_EXPORT QGeoTiledMapTileContainerNode : public QSGTransformNode +{ +public: + void addChild(const QGeoTileSpec &spec, QSGImageNode *node) + { + tiles.insert(spec, node); + appendChildNode(node); + } + QHash tiles; +}; + +class Q_LOCATION_PRIVATE_EXPORT QGeoTiledMapRootNode : public QSGClipNode +{ +public: + QGeoTiledMapRootNode() + : isTextureLinear(false) + , geometry(QSGGeometry::defaultAttributes_Point2D(), 4) + , root(new QSGTransformNode()) + , tiles(new QGeoTiledMapTileContainerNode()) + , wrapLeft(new QGeoTiledMapTileContainerNode()) + , wrapRight(new QGeoTiledMapTileContainerNode()) + { + setIsRectangular(true); + setGeometry(&geometry); + root->appendChildNode(tiles); + root->appendChildNode(wrapLeft); + root->appendChildNode(wrapRight); + appendChildNode(root); + } + + ~QGeoTiledMapRootNode() + { + qDeleteAll(textures); + } + + void setClipRect(const QRect &rect) + { + if (rect != clipRect) { + QSGGeometry::updateRectGeometry(&geometry, rect); + QSGClipNode::setClipRect(rect); + clipRect = rect; + markDirty(DirtyGeometry); + } + } + + void updateTiles(QGeoTiledMapTileContainerNode *root, + QGeoTiledMapScenePrivate *d, + double camAdjust, + QQuickWindow *window, + bool ogl); + + bool isTextureLinear; + + QSGGeometry geometry; + QRect clipRect; + + QSGTransformNode *root; + + QGeoTiledMapTileContainerNode *tiles; // The majority of the tiles + QGeoTiledMapTileContainerNode *wrapLeft; // When zoomed out, the tiles that wrap around on the left. + QGeoTiledMapTileContainerNode *wrapRight; // When zoomed out, the tiles that wrap around on the right + + QHash textures; + +#ifdef QT_LOCATION_DEBUG + double m_sideLengthPixel; + QMap> m_droppedTiles; +#endif +}; + +class Q_LOCATION_PRIVATE_EXPORT QGeoTiledMapScenePrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QGeoTiledMapScene) +public: + QGeoTiledMapScenePrivate(); + ~QGeoTiledMapScenePrivate(); + + void addTile(const QGeoTileSpec &spec, QSharedPointer texture); + + void setVisibleTiles(const QSet &visibleTiles); + void removeTiles(const QSet &oldTiles); + bool buildGeometry(const QGeoTileSpec &spec, QSGImageNode *imageNode, bool &overzooming); + void updateTileBounds(const QSet &tiles); + void setupCamera(); + inline bool isTiltedOrRotated() { return (m_cameraData.tilt() > 0.0) || (m_cameraData.bearing() > 0.0); } + +public: + + QSize m_screenSize; // in pixels + int m_tileSize; // the pixel resolution for each tile + QGeoCameraData m_cameraData; + QRectF m_visibleArea; + QSet m_visibleTiles; + + QDoubleVector3D m_cameraUp; + QDoubleVector3D m_cameraEye; + QDoubleVector3D m_cameraCenter; + QMatrix4x4 m_projectionMatrix; + + // scales up the tile geometry and the camera altitude, resulting in no visible effect + // other than to control the accuracy of the render by keeping the values in a sensible range + double m_scaleFactor; + + // rounded down, positive zoom is zooming in, corresponding to reduced altitude + int m_intZoomLevel; + + // mercatorToGrid transform + // the number of tiles in each direction for the whole map (earth) at the current zoom level. + // it is 1< > m_textures; + QVector m_updatedTextures; + + // tilesToGrid transform + int m_minTileX; // the minimum tile index, i.e. 0 to sideLength which is 1<< zoomLevel + int m_minTileY; + int m_maxTileX; + int m_maxTileY; + int m_tileXWrapsBelow; // the wrap point as a tile index + bool m_linearScaling; + bool m_dropTextures; + +#ifdef QT_LOCATION_DEBUG + double m_sideLengthPixel; + QGeoTiledMapRootNode *m_mapRoot = nullptr; +#endif +}; + +QT_END_NAMESPACE + +#endif // QGEOTILEDMAPSCENE_P_P_H -- cgit v1.2.1 From b4beb74d93fee205b624c0f0ae6ea39d88d471ac Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Wed, 28 Nov 2018 10:44:35 +0100 Subject: Fix compilation with GCC < 5.0 Apparently unable to resolve QPointers to pointers Change-Id: I04b3b7698ea083f83bc2713530656ca8b3f3ac28 Fixes: QTBUG-69512 Reviewed-by: Alex Blasche --- src/location/declarativemaps/qdeclarativegeomap.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp index 09f9d01c..d8d01b66 100644 --- a/src/location/declarativemaps/qdeclarativegeomap.cpp +++ b/src/location/declarativemaps/qdeclarativegeomap.cpp @@ -694,11 +694,11 @@ void QDeclarativeGeoMap::mappingManagerInitialized() QImage copyrightImage; if (!m_initialized && width() > 0 && height() > 0) { QMetaObject::Connection copyrightStringCatcherConnection = - connect(m_map, + connect(m_map.data(), QOverload::of(&QGeoMap::copyrightsChanged), [©rightString](const QString ©){ copyrightString = copy; }); QMetaObject::Connection copyrightImageCatcherConnection = - connect(m_map, + connect(m_map.data(), QOverload::of(&QGeoMap::copyrightsChanged), [©rightImage](const QImage ©){ copyrightImage = copy; }); m_map->setViewportSize(QSize(width(), height())); @@ -709,9 +709,9 @@ void QDeclarativeGeoMap::mappingManagerInitialized() /* COPYRIGHT SIGNALS REWIRING */ - connect(m_map, SIGNAL(copyrightsChanged(QImage)), + connect(m_map.data(), SIGNAL(copyrightsChanged(QImage)), this, SIGNAL(copyrightsChanged(QImage))); - connect(m_map, SIGNAL(copyrightsChanged(QString)), + connect(m_map.data(), SIGNAL(copyrightsChanged(QString)), this, SIGNAL(copyrightsChanged(QString))); if (!copyrightString.isEmpty()) emit m_map->copyrightsChanged(copyrightString); @@ -719,8 +719,8 @@ void QDeclarativeGeoMap::mappingManagerInitialized() emit m_map->copyrightsChanged(copyrightImage); - connect(m_map, &QGeoMap::sgNodeChanged, this, &QQuickItem::update); - connect(m_map, &QGeoMap::cameraCapabilitiesChanged, this, &QDeclarativeGeoMap::onCameraCapabilitiesChanged); + connect(m_map.data(), &QGeoMap::sgNodeChanged, this, &QQuickItem::update); + connect(m_map.data(), &QGeoMap::cameraCapabilitiesChanged, this, &QDeclarativeGeoMap::onCameraCapabilitiesChanged); // This prefetches a buffer around the map m_map->prefetchData(); -- cgit v1.2.1 From 4e2847bc1a86634d6d583b33a7e246ff4c58e03b Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Fri, 30 Nov 2018 18:06:25 +0100 Subject: Fix regression in error handling in QGeoServiceProvider cb19e1f7e3cc2cfee3b8fcbdfa5cd151826dadac fixed a bogus comparison in an if statement. However, the correct condition is actually a bug, and should be removed altogether. The previously incorrect condition was always testing to false so the problem wasn't triggered. Task-number: QTBUG-72180 Change-Id: Ia00b55596173474e8c0fe3b0c374490620c6917f Reviewed-by: Alex Blasche --- src/location/maps/qgeoserviceprovider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp index 27332e88..d25c379a 100644 --- a/src/location/maps/qgeoserviceprovider.cpp +++ b/src/location/maps/qgeoserviceprovider.cpp @@ -381,7 +381,7 @@ Manager *QGeoServiceProviderPrivate::manager(QGeoServiceProvider::Error *_error, this->loadPlugin(this->parameterMap); } - if (!this->factory || this->error != QGeoServiceProvider::NoError) { + if (!this->factory) { error = this->error; errorString = this->errorString; return 0; -- cgit v1.2.1 From 7bafbdc91f83165710ed74639b76b48b4494937a Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Mon, 3 Dec 2018 14:31:26 +0200 Subject: Fix compilation with gcc 4.8 GCC 4.8 doesn't like using QPointer in signal connections. Change-Id: I9504efb259712a65427ef1366ca562882085404e Reviewed-by: Simon Hausmann --- src/location/declarativemaps/qdeclarativegeomap.cpp | 16 ++++++++-------- src/location/maps/qgeomap_p.h | 1 - .../geoclue2/qgeopositioninfosource_geoclue2.cpp | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp index b0adc54c..63587efe 100644 --- a/src/location/declarativemaps/qdeclarativegeomap.cpp +++ b/src/location/declarativemaps/qdeclarativegeomap.cpp @@ -360,7 +360,7 @@ void QDeclarativeGeoMap::initialize() center.setLatitude(qBound(m_minimumViewportLatitude, center.latitude(), m_maximumViewportLatitude)); cameraData.setCenter(center); - connect(m_map, &QGeoMap::cameraDataChanged, + connect(m_map.data(), &QGeoMap::cameraDataChanged, this, &QDeclarativeGeoMap::onCameraDataChanged); m_map->setCameraData(cameraData); @@ -371,7 +371,7 @@ void QDeclarativeGeoMap::initialize() if (visibleAreaHasChanged) emit visibleAreaChanged(); - connect(m_map, &QGeoMap::visibleAreaChanged, this, &QDeclarativeGeoMap::visibleAreaChanged); + connect(m_map.data(), &QGeoMap::visibleAreaChanged, this, &QDeclarativeGeoMap::visibleAreaChanged); emit mapReadyChanged(true); @@ -657,11 +657,11 @@ void QDeclarativeGeoMap::mappingManagerInitialized() QImage copyrightImage; if (!m_initialized && width() > 0 && height() > 0) { QMetaObject::Connection copyrightStringCatcherConnection = - connect(m_map, + connect(m_map.data(), QOverload::of(&QGeoMap::copyrightsChanged), [©rightString](const QString ©){ copyrightString = copy; }); QMetaObject::Connection copyrightImageCatcherConnection = - connect(m_map, + connect(m_map.data(), QOverload::of(&QGeoMap::copyrightsChanged), [©rightImage](const QImage ©){ copyrightImage = copy; }); m_map->setViewportSize(QSize(width(), height())); @@ -672,9 +672,9 @@ void QDeclarativeGeoMap::mappingManagerInitialized() /* COPYRIGHT SIGNALS REWIRING */ - connect(m_map, SIGNAL(copyrightsChanged(QImage)), + connect(m_map.data(), SIGNAL(copyrightsChanged(QImage)), this, SIGNAL(copyrightsChanged(QImage))); - connect(m_map, SIGNAL(copyrightsChanged(QString)), + connect(m_map.data(), SIGNAL(copyrightsChanged(QString)), this, SIGNAL(copyrightsChanged(QString))); if (!copyrightString.isEmpty()) emit m_map->copyrightsChanged(copyrightString); @@ -682,8 +682,8 @@ void QDeclarativeGeoMap::mappingManagerInitialized() emit m_map->copyrightsChanged(copyrightImage); - connect(m_map, &QGeoMap::sgNodeChanged, this, &QQuickItem::update); - connect(m_map, &QGeoMap::cameraCapabilitiesChanged, this, &QDeclarativeGeoMap::onCameraCapabilitiesChanged); + connect(m_map.data(), &QGeoMap::sgNodeChanged, this, &QQuickItem::update); + connect(m_map.data(), &QGeoMap::cameraCapabilitiesChanged, this, &QDeclarativeGeoMap::onCameraCapabilitiesChanged); // This prefetches a buffer around the map m_map->prefetchData(); diff --git a/src/location/maps/qgeomap_p.h b/src/location/maps/qgeomap_p.h index f19f847a..874b300f 100644 --- a/src/location/maps/qgeomap_p.h +++ b/src/location/maps/qgeomap_p.h @@ -177,7 +177,6 @@ Q_SIGNALS: private: Q_DISABLE_COPY(QGeoMap) friend class QDeclarativeGeoMap; //updateSceneGraph - friend class QGeoMapPrivate; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoMap::ItemTypes) diff --git a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp b/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp index cd514d30..10484e3b 100644 --- a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp +++ b/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp @@ -264,7 +264,7 @@ void QGeoPositionInfoSourceGeoclue2::createClient() setError(AccessError); delete m_client; } else { - connect(m_client, &OrgFreedesktopGeoClue2ClientInterface::LocationUpdated, + connect(m_client.data(), &OrgFreedesktopGeoClue2ClientInterface::LocationUpdated, this, &QGeoPositionInfoSourceGeoclue2::handleNewLocation); if (configureClient()) -- cgit v1.2.1 From cfb917948799cb177b3de7eced77f37d13b4e520 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 2 Dec 2018 14:30:39 +0100 Subject: Port Nokia geo service plugin to QRegularExpression This patch updates the Nokia geo service plugin code to use QRegularExpression in place of QRegExp which is to be considered deprecated. Change-Id: Idc7459351c6f1a1b12ba1528c426fced324039a1 Reviewed-by: Alex Blasche --- src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp index ab575463..5094b72e 100644 --- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp +++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -690,13 +691,14 @@ QPlaceIcon QPlaceManagerEngineNokiaV2::icon(const QString &remotePath, QPlaceIcon icon; QVariantMap params; - QRegExp rx("(.*)(/icons/categories/.*)"); + QRegularExpression rx("(.*)(/icons/categories/.*)"); + QRegularExpressionMatch match = rx.match(remotePath); QString iconPrefix; QString nokiaIcon; - if (rx.indexIn(remotePath) != -1 && !rx.cap(1).isEmpty() && !rx.cap(2).isEmpty()) { - iconPrefix = rx.cap(1); - nokiaIcon = rx.cap(2); + if (match.hasMatch() && !match.capturedRef(1).isEmpty() && !match.capturedRef(2).isEmpty()) { + iconPrefix = match.captured(1); + nokiaIcon = match.captured(2); if (QFile::exists(m_localDataPath + nokiaIcon)) iconPrefix = QString::fromLatin1("file://") + m_localDataPath; -- cgit v1.2.1 From 74c390e10f6d2f72fc81eca291b84762ccfb344e Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 5 Dec 2018 13:28:06 +0100 Subject: Fix warning in Android position plugin qtlocation/src/plugins/position/android/src/qgeopositioninfosource_android.cpp:226: warning: implicit conversion loses integer precision: 'qint64' (aka 'long long') to 'const int' Change-Id: I64df529028aac88f1b6e05c72cfba0a9ed6c9a7f Reviewed-by: Paolo Angelelli --- src/plugins/position/android/src/qgeopositioninfosource_android.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp index 7b4706d8..76b7a388 100644 --- a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp +++ b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp @@ -223,7 +223,7 @@ void QGeoPositionInfoSourceAndroid::requestTimeout() const QGeoPositionInfo info = queuedSingleUpdates[i]; //anything newer by 20s is always better - const int timeDelta = best.timestamp().secsTo(info.timestamp()); + const qint64 timeDelta = best.timestamp().secsTo(info.timestamp()); if (abs(timeDelta) > 20) { if (timeDelta > 0) best = info; -- cgit v1.2.1 From 3d38d96c44d376a10cbe140f7b7c6866bd203471 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 5 Dec 2018 15:02:53 +0100 Subject: Fix horizontal accuracy comparison for competing position results Fixes: QTBUG-72291 Change-Id: Id2c2ce04e12f1470b08e93ec3512ab39b4054f7d Reviewed-by: Paolo Angelelli --- src/plugins/position/android/src/qgeopositioninfosource_android.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp index 76b7a388..59b8beab 100644 --- a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp +++ b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp @@ -232,7 +232,7 @@ void QGeoPositionInfoSourceAndroid::requestTimeout() //compare accuracy if (info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy) && - info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) + best.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) { best = info.attribute(QGeoPositionInfo::HorizontalAccuracy) < best.attribute(QGeoPositionInfo::HorizontalAccuracy) ? info : best; -- cgit v1.2.1