diff options
Diffstat (limited to 'src')
39 files changed, 254 insertions, 133 deletions
diff --git a/src/3rdparty/earcut/earcut.hpp b/src/3rdparty/earcut/earcut.hpp index ba3fb17a..d0b0c41e 100644 --- a/src/3rdparty/earcut/earcut.hpp +++ b/src/3rdparty/earcut/earcut.hpp @@ -1,8 +1,29 @@ +/**************************************************************************** +** earcut.hpp v2.2.1 +** +** ISC License +** +** Copyright (c) 2015, Mapbox +** +** Permission to use, copy, modify, and/or distribute this software for any purpose +** with or without fee is hereby granted, provided that the above copyright notice +** and this permission notice appear in all copies. +** +** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +** REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +** FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +** INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +** OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +** THIS SOFTWARE. +****************************************************************************/ + #pragma once #ifndef EARCUT_HPP #define EARCUT_HPP -#include <array> +#pragma once + #include <algorithm> #include <cassert> #include <cmath> @@ -14,12 +35,10 @@ namespace qt_mapbox { namespace util { template <std::size_t I, typename T> struct nth { - inline static typename std::tuple_element<I, T>::type - get(const T& t) { return std::get<I>(t); } + get(const T& t) { return std::get<I>(t); }; }; - } namespace detail { @@ -28,7 +47,7 @@ template <typename N = uint32_t> class Earcut { public: std::vector<N> indices; - N vertices = 0; + std::size_t vertices = 0; template <typename Polygon> void operator()(const Polygon& points); @@ -70,6 +89,7 @@ private: template <typename Polygon> Node* eliminateHoles(const Polygon& points, Node* outerNode); void eliminateHole(Node* hole, Node* outerNode); Node* findHoleBridge(Node* hole, Node* outerNode); + bool sectorContainsSector(const Node* m, const Node* p); void indexCurve(Node* start); Node* sortLinked(Node* list); int32_t zOrder(const double x_, const double y_); @@ -79,17 +99,19 @@ private: double area(const Node* p, const Node* q, const Node* r) const; bool equals(const Node* p1, const Node* p2); bool intersects(const Node* p1, const Node* q1, const Node* p2, const Node* q2); + bool onSegment(const Node* p, const Node* q, const Node* r); + int sign(double val); bool intersectsPolygon(const Node* a, const Node* b); bool locallyInside(const Node* a, const Node* b); bool middleInside(const Node* a, const Node* b); Node* splitPolygon(Node* a, Node* b); - template <typename Point> Node* insertNode(N i, const Point& p, Node* last); + template <typename Point> Node* insertNode(std::size_t i, const Point& p, Node* last); void removeNode(Node* p); bool hashing; double minX, maxX; double minY, maxY; - double size; + double inv_size = 0; template <typename T, typename Alloc = std::allocator<T>> class ObjectPool { @@ -104,16 +126,18 @@ private: template <typename... Args> T* construct(Args&&... args) { if (currentIndex >= blockSize) { - currentBlock = alloc.allocate(blockSize); + currentBlock = alloc_traits::allocate(alloc, blockSize); allocations.emplace_back(currentBlock); currentIndex = 0; } T* object = ¤tBlock[currentIndex++]; - alloc.construct(object, std::forward<Args>(args)...); + alloc_traits::construct(alloc, object, std::forward<Args>(args)...); return object; } void reset(std::size_t newBlockSize) { - for (auto allocation : allocations) alloc.deallocate(allocation, blockSize); + for (auto allocation : allocations) { + alloc_traits::deallocate(alloc, allocation, blockSize); + } allocations.clear(); blockSize = std::max<std::size_t>(1, newBlockSize); currentBlock = nullptr; @@ -126,6 +150,7 @@ private: std::size_t blockSize = 1; std::vector<T*> allocations; Alloc alloc; + typedef typename std::allocator_traits<Alloc> alloc_traits; }; ObjectPool<Node> nodes; }; @@ -140,7 +165,6 @@ void Earcut<N>::operator()(const Polygon& points) { double x; double y; - size = 0; int threshold = 80; std::size_t len = 0; @@ -154,7 +178,7 @@ void Earcut<N>::operator()(const Polygon& points) { indices.reserve(len + points[0].size()); Node* outerNode = linkedList(points[0], true); - if (!outerNode) return; + if (!outerNode || outerNode->prev == outerNode->next) return; if (points.size() > 1) outerNode = eliminateHoles(points, outerNode); @@ -162,20 +186,21 @@ void Earcut<N>::operator()(const Polygon& points) { hashing = threshold < 0; if (hashing) { Node* p = outerNode->next; - minX = maxX = p->x; - minY = maxY = p->y; + minX = maxX = outerNode->x; + minY = maxY = outerNode->y; do { x = p->x; y = p->y; - minX = (std::min)(minX, x); - minY = (std::min)(minY, y); - maxX = (std::max)(maxX, x); - maxY = (std::max)(maxY, y); + minX = std::min<double>(minX, x); + minY = std::min<double>(minY, y); + maxX = std::max<double>(maxX, x); + maxY = std::max<double>(maxY, y); p = p->next; } while (p != outerNode); // minX, minY and size are later used to transform coords into integers for z-order calculation - size = (std::max)(maxX - minX, maxY - minY); + inv_size = std::max<double>(maxX - minX, maxY - minY); + inv_size = inv_size != .0 ? (1. / inv_size) : .0; } earcutLinked(outerNode); @@ -189,15 +214,14 @@ typename Earcut<N>::Node* Earcut<N>::linkedList(const Ring& points, const bool clockwise) { using Point = typename Ring::value_type; double sum = 0; - const int len = static_cast<int>(points.size()); - int i, j; - Point p1, p2; + const std::size_t len = points.size(); + std::size_t i, j; Node* last = nullptr; // calculate original winding order of a polygon ring - for (i = 0, j = len - 1; i < len; j = i++) { - p1 = points[i]; - p2 = points[j]; + for (i = 0, j = len > 0 ? len - 1 : 0; i < len; j = i++) { + const auto& p1 = points[i]; + const auto& p2 = points[j]; const double p20 = util::nth<0, Point>::get(p2); const double p10 = util::nth<0, Point>::get(p1); const double p11 = util::nth<1, Point>::get(p1); @@ -209,7 +233,7 @@ Earcut<N>::linkedList(const Ring& points, const bool clockwise) { if (clockwise == (sum > 0)) { for (i = 0; i < len; i++) last = insertNode(vertices + i, points[i], last); } else { - for (i = len - 1; i >= 0; i--) last = insertNode(vertices + i, points[i], last); + for (i = len; i-- > 0;) last = insertNode(vertices + i, points[i], last); } if (last && equals(last, last->next)) { @@ -237,7 +261,7 @@ Earcut<N>::filterPoints(Node* start, Node* end) { removeNode(p); p = end = p->prev; - if (p == p->next) return nullptr; + if (p == p->next) break; again = true; } else { @@ -292,10 +316,10 @@ void Earcut<N>::earcutLinked(Node* ear, int pass) { // if this didn't work, try curing all small self-intersections locally else if (pass == 1) { - ear = cureLocalIntersections(ear); + ear = cureLocalIntersections(filterPoints(ear)); earcutLinked(ear, 2); - // as a last resort, try splitting the remaining polygon into two + // as a last resort, try splitting the remaining polygon into two } else if (pass == 2) splitEarcut(ear); break; @@ -317,7 +341,7 @@ bool Earcut<N>::isEar(Node* ear) { while (p != ear->prev) { if (pointInTriangle(a->x, a->y, b->x, b->y, c->x, c->y, p->x, p->y) && - area(p->prev, p, p->next) >= 0) return false; + area(p->prev, p, p->next) >= 0) return false; p = p->next; } @@ -333,10 +357,10 @@ bool Earcut<N>::isEarHashed(Node* ear) { if (area(a, b, c) >= 0) return false; // reflex, can't be an ear // triangle bbox; min & max are calculated like this for speed - const double minTX = (std::min)(a->x, (std::min)(b->x, c->x)); - const double minTY = (std::min)(a->y, (std::min)(b->y, c->y)); - const double maxTX = (std::max)(a->x, (std::max)(b->x, c->x)); - const double maxTY = (std::max)(a->y, (std::max)(b->y, c->y)); + const double minTX = std::min<double>(a->x, std::min<double>(b->x, c->x)); + const double minTY = std::min<double>(a->y, std::min<double>(b->y, c->y)); + const double maxTX = std::max<double>(a->x, std::max<double>(b->x, c->x)); + const double maxTY = std::max<double>(a->y, std::max<double>(b->y, c->y)); // z-order range for the current triangle bbox; const int32_t minZ = zOrder(minTX, minTY); @@ -347,8 +371,8 @@ bool Earcut<N>::isEarHashed(Node* ear) { while (p && p->z <= maxZ) { if (p != ear->prev && p != ear->next && - pointInTriangle(a->x, a->y, b->x, b->y, c->x, c->y, p->x, p->y) && - area(p->prev, p, p->next) >= 0) return false; + pointInTriangle(a->x, a->y, b->x, b->y, c->x, c->y, p->x, p->y) && + area(p->prev, p, p->next) >= 0) return false; p = p->nextZ; } @@ -357,8 +381,8 @@ bool Earcut<N>::isEarHashed(Node* ear) { while (p && p->z >= minZ) { if (p != ear->prev && p != ear->next && - pointInTriangle(a->x, a->y, b->x, b->y, c->x, c->y, p->x, p->y) && - area(p->prev, p, p->next) >= 0) return false; + pointInTriangle(a->x, a->y, b->x, b->y, c->x, c->y, p->x, p->y) && + area(p->prev, p, p->next) >= 0) return false; p = p->prevZ; } @@ -389,7 +413,7 @@ Earcut<N>::cureLocalIntersections(Node* start) { p = p->next; } while (p != start); - return p; + return filterPoints(p); } // try splitting polygon into two and triangulate them independently @@ -470,22 +494,22 @@ Earcut<N>::findHoleBridge(Node* hole, Node* outerNode) { // segment's endpoint with lesser x will be potential connection Vertex do { if (hy <= p->y && hy >= p->next->y && p->next->y != p->y) { - double x = p->x + (hy - p->y) * (p->next->x - p->x) / (p->next->y - p->y); - if (x <= hx && x > qx) { - qx = x; - if (x == hx) { - if (hy == p->y) return p; - if (hy == p->next->y) return p->next; + double x = p->x + (hy - p->y) * (p->next->x - p->x) / (p->next->y - p->y); + if (x <= hx && x > qx) { + qx = x; + if (x == hx) { + if (hy == p->y) return p; + if (hy == p->next->y) return p->next; + } + m = p->x < p->next->x ? p : p->next; } - m = p->x < p->next->x ? p : p->next; - } } p = p->next; } while (p != outerNode); if (!m) return 0; - if (hx == qx) return m->prev; + if (hx == qx) return m; // hole touches outer segment; pick leftmost endpoint // look for points inside the triangle of hole Vertex, segment intersection and endpoint; // if there are no points found, we have a valid connection; @@ -495,28 +519,35 @@ Earcut<N>::findHoleBridge(Node* hole, Node* outerNode) { double tanMin = std::numeric_limits<double>::infinity(); double tanCur = 0; - p = m->next; + p = m; double mx = m->x; double my = m->y; - while (p != stop) { + do { if (hx >= p->x && p->x >= mx && hx != p->x && - pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p->x, p->y)) { + pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p->x, p->y)) { tanCur = std::abs(hy - p->y) / (hx - p->x); // tangential - if ((tanCur < tanMin || (tanCur == tanMin && p->x > m->x)) && locallyInside(p, hole)) { + if (locallyInside(p, hole) && + (tanCur < tanMin || (tanCur == tanMin && (p->x > m->x || sectorContainsSector(m, p))))) { m = p; tanMin = tanCur; } } p = p->next; - } + } while (p != stop); return m; } +// whether sector in vertex m contains sector in vertex p in the same coordinates +template <typename N> +bool Earcut<N>::sectorContainsSector(const Node* m, const Node* p) { + return area(m->prev, m, p->prev) < 0 && area(p->next, m, m->next) < 0; +} + // interlink polygon nodes in z-order template <typename N> void Earcut<N>::indexCurve(Node* start) { @@ -549,7 +580,7 @@ Earcut<N>::sortLinked(Node* list) { int i, numMerges, pSize, qSize; int inSize = 1; - while (true) { + for (;;) { p = list; list = nullptr; tail = nullptr; @@ -609,8 +640,8 @@ Earcut<N>::sortLinked(Node* list) { template <typename N> int32_t Earcut<N>::zOrder(const double x_, const double y_) { // coords are transformed into non-negative 15-bit integer range - int32_t x = static_cast<int32_t>(32767.0 * (x_ - minX) / size); - int32_t y = static_cast<int32_t>(32767.0 * (y_ - minY) / size); + int32_t x = static_cast<int32_t>(32767.0 * (x_ - minX) * inv_size); + int32_t y = static_cast<int32_t>(32767.0 * (y_ - minY) * inv_size); x = (x | (x << 8)) & 0x00FF00FF; x = (x | (x << 4)) & 0x0F0F0F0F; @@ -632,7 +663,8 @@ Earcut<N>::getLeftmost(Node* start) { Node* p = start; Node* leftmost = start; do { - if (p->x < leftmost->x) leftmost = p; + if (p->x < leftmost->x || (p->x == leftmost->x && p->y < leftmost->y)) + leftmost = p; p = p->next; } while (p != start); @@ -643,15 +675,17 @@ Earcut<N>::getLeftmost(Node* start) { template <typename N> bool Earcut<N>::pointInTriangle(double ax, double ay, double bx, double by, double cx, double cy, double px, double py) const { return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && - (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && - (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; + (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && + (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; } // check if a diagonal between two polygon nodes is valid (lies in polygon interior) template <typename N> bool Earcut<N>::isValidDiagonal(Node* a, Node* b) { - return a->next->i != b->i && a->prev->i != b->i && !intersectsPolygon(a, b) && - locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); + return a->next->i != b->i && a->prev->i != b->i && !intersectsPolygon(a, b) && // dones't intersect other edges + ((locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible + (area(a->prev, a, b->prev) != 0.0 || area(a, b->prev, b) != 0.0)) || // does not create opposite-facing sectors + (equals(a, b) && area(a->prev, a, a->next) > 0 && area(b->prev, b, b->next) > 0)); // special zero-length case } // signed area of a triangle @@ -669,10 +703,33 @@ bool Earcut<N>::equals(const Node* p1, const Node* p2) { // check if two segments intersect template <typename N> bool Earcut<N>::intersects(const Node* p1, const Node* q1, const Node* p2, const Node* q2) { - if ((equals(p1, q1) && equals(p2, q2)) || - (equals(p1, q2) && equals(p2, q1))) return true; - return (area(p1, q1, p2) > 0) != (area(p1, q1, q2) > 0) && - (area(p2, q2, p1) > 0) != (area(p2, q2, q1) > 0); + int o1 = sign(area(p1, q1, p2)); + int o2 = sign(area(p1, q1, q2)); + int o3 = sign(area(p2, q2, p1)); + int o4 = sign(area(p2, q2, q1)); + + if (o1 != o2 && o3 != o4) return true; // general case + + if (o1 == 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1 + if (o2 == 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1 + if (o3 == 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2 + if (o4 == 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2 + + return false; +} + +// for collinear points p, q, r, check if point q lies on segment pr +template <typename N> +bool Earcut<N>::onSegment(const Node* p, const Node* q, const Node* r) { + return q->x <= std::max<double>(p->x, r->x) && + q->x >= std::min<double>(p->x, r->x) && + q->y <= std::max<double>(p->y, r->y) && + q->y >= std::min<double>(p->y, r->y); +} + +template <typename N> +int Earcut<N>::sign(double val) { + return (0.0 < val) - (val < 0.0); } // check if a polygon diagonal intersects any polygon segments @@ -692,8 +749,8 @@ bool Earcut<N>::intersectsPolygon(const Node* a, const Node* b) { template <typename N> bool Earcut<N>::locallyInside(const Node* a, const Node* b) { return area(a->prev, a, a->next) < 0 ? - area(a, b, a->next) >= 0 && area(a, a->prev, b) >= 0 : - area(a, b, a->prev) < 0 || area(a, a->next, b) < 0; + area(a, b, a->next) >= 0 && area(a, a->prev, b) >= 0 : + area(a, b, a->prev) < 0 || area(a, a->next, b) < 0; } // check if the middle Vertex of a polygon diagonal is inside the polygon @@ -742,8 +799,8 @@ Earcut<N>::splitPolygon(Node* a, Node* b) { // create a node and util::optionally link it with previous one (in a circular doubly linked list) template <typename N> template <typename Point> typename Earcut<N>::Node* -Earcut<N>::insertNode(N i, const Point& pt, Node* last) { - Node* p = nodes.construct(i, util::nth<0, Point>::get(pt), util::nth<1, Point>::get(pt)); +Earcut<N>::insertNode(std::size_t i, const Point& pt, Node* last) { + Node* p = nodes.construct(static_cast<N>(i), util::nth<0, Point>::get(pt), util::nth<1, Point>::get(pt)); if (!last) { p->prev = p; @@ -773,7 +830,8 @@ template <typename N = uint32_t, typename Polygon> std::vector<N> earcut(const Polygon& poly) { qt_mapbox::detail::Earcut<N> earcut; earcut(poly); - return earcut.indices; + return std::move(earcut.indices); } } + #endif //EARCUT_HPP diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp index 7fd5f78a..6a2d82e8 100644 --- a/src/location/declarativemaps/qdeclarativegeomap.cpp +++ b/src/location/declarativemaps/qdeclarativegeomap.cpp @@ -2289,17 +2289,31 @@ void QDeclarativeGeoMap::geometryChanged(const QRectF &newGeometry, const QRectF } /*! - \qmlmethod void QtLocation::Map::fitViewportToMapItems() + \qmlmethod void QtLocation::Map::fitViewportToMapItems(list<MapItems> items = {}) - Fits the current viewport to the boundary of all map items. The camera is positioned - in the center of the map items, and at the largest integral zoom level possible which - allows all map items to be visible on screen. + If no argument is provided, fits the current viewport to the boundary of all map items. + The camera is positioned in the center of the map items, and at the largest integral zoom level + possible which allows all map items to be visible on screen. + If \a items is provided, fits the current viewport to the boundary of the specified map items only. + + \note This method gained the optional \a items argument since Qt 5.15. + In previous releases, this method fitted the map to all map items. \sa fitViewportToVisibleMapItems */ -void QDeclarativeGeoMap::fitViewportToMapItems() +void QDeclarativeGeoMap::fitViewportToMapItems(const QVariantList &items) { - fitViewportToMapItemsRefine(true, false); + if (items.size()) { + QList<QPointer<QDeclarativeGeoMapItemBase> > itms; + for (const QVariant &i: items) { + QDeclarativeGeoMapItemBase *itm = qobject_cast<QDeclarativeGeoMapItemBase *>(i.value<QObject *>()); + if (itm) + itms.append(itm); + } + fitViewportToMapItemsRefine(itms, true, false); + } else { + fitViewportToMapItemsRefine(m_mapItems, true, false); + } } /*! @@ -2313,18 +2327,20 @@ void QDeclarativeGeoMap::fitViewportToMapItems() */ void QDeclarativeGeoMap::fitViewportToVisibleMapItems() { - fitViewportToMapItemsRefine(true, true); + fitViewportToMapItemsRefine(m_mapItems, true, true); } /*! \internal */ -void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine, bool onlyVisible) +void QDeclarativeGeoMap::fitViewportToMapItemsRefine(const QList<QPointer<QDeclarativeGeoMapItemBase> > &mapItems, + bool refine, + bool onlyVisible) { if (!m_map) return; - if (m_mapItems.size() == 0) + if (mapItems.size() == 0) return; double minX = qInf(); @@ -2339,10 +2355,10 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine, bool onlyVisib // find bounds of all map items int itemCount = 0; - for (int i = 0; i < m_mapItems.count(); ++i) { - if (!m_mapItems.at(i)) + for (int i = 0; i < mapItems.count(); ++i) { + if (!mapItems.at(i)) continue; - QDeclarativeGeoMapItemBase *item = m_mapItems.at(i).data(); + QDeclarativeGeoMapItemBase *item = mapItems.at(i).data(); if (!item || (onlyVisible && (!item->isVisible() || item->mapItemOpacity() <= 0.0))) continue; @@ -2393,7 +2409,7 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine, bool onlyVisib if (itemCount == 0) { if (haveQuickItem) - fitViewportToMapItemsRefine(false, onlyVisible); + fitViewportToMapItemsRefine(mapItems, false, onlyVisible); return; } double bboxWidth = maxX - minX; @@ -2423,7 +2439,7 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine, bool onlyVisib // as map quick items retain the same screen size after the camera zooms in/out // we refine the viewport again to achieve better results if (refine) - fitViewportToMapItemsRefine(false, onlyVisible); + fitViewportToMapItemsRefine(mapItems, false, onlyVisible); } /*! diff --git a/src/location/declarativemaps/qdeclarativegeomap_p.h b/src/location/declarativemaps/qdeclarativegeomap_p.h index c97c3622..ee9f8ec2 100644 --- a/src/location/declarativemaps/qdeclarativegeomap_p.h +++ b/src/location/declarativemaps/qdeclarativegeomap_p.h @@ -193,7 +193,7 @@ public: QQuickGeoMapGestureArea *gesture(); - Q_INVOKABLE void fitViewportToMapItems(); + Q_INVOKABLE void fitViewportToMapItems(const QVariantList &items = {}); Q_INVOKABLE void fitViewportToVisibleMapItems(); Q_INVOKABLE void pan(int dx, int dy); Q_INVOKABLE void prefetchData(); // optional hint for prefetch @@ -280,7 +280,7 @@ private: void setupMapView(QDeclarativeGeoMapItemView *view); void populateMap(); void populateParameters(); - void fitViewportToMapItemsRefine(bool refine, bool onlyVisible); + void fitViewportToMapItemsRefine(const QList<QPointer<QDeclarativeGeoMapItemBase> > &mapItems, bool refine, bool onlyVisible); bool isInteractive(); void attachCopyrightNotice(bool initialVisibility); void detachCopyrightNotice(bool currentVisibility); diff --git a/src/location/declarativemaps/qgeomapobject.cpp b/src/location/declarativemaps/qgeomapobject.cpp index 00faac9b..b0a10806 100644 --- a/src/location/declarativemaps/qgeomapobject.cpp +++ b/src/location/declarativemaps/qgeomapobject.cpp @@ -193,8 +193,10 @@ void QGeoMapObject::setMap(QGeoMap *map) if (map) { bool oldVisible = d_ptr->m_visible; bool oldCmponentCompleted = d_ptr->m_componentCompleted; - if (!map->createMapObjectImplementation(this)) - qWarning() << "Unsupported type " << type(); + if (!map->createMapObjectImplementation(this)) { + if (type() != ViewType) + qWarning() << "Unsupported type " << type(); + } // old implementation gets destroyed if/when d_ptr gets replaced d_ptr->m_componentCompleted = oldCmponentCompleted; d_ptr->setVisible(oldVisible); diff --git a/src/location/declarativemaps/qparameterizableobject.cpp b/src/location/declarativemaps/qparameterizableobject.cpp index 0e138b86..26d9a11e 100644 --- a/src/location/declarativemaps/qparameterizableobject.cpp +++ b/src/location/declarativemaps/qparameterizableobject.cpp @@ -37,13 +37,10 @@ #include "qparameterizableobject_p.h" #include "qdeclarativegeomapparameter_p.h" #include <QtLocation/private/qgeomapparameter_p.h> +#include <private/qobject_p.h> QT_BEGIN_NAMESPACE -QParameterizableObject::QParameterizableObject(QObject *parent) - : QObject(parent) -{} - void QParameterizableObject::appendChild(QObject *v) { m_children.append(v); @@ -85,4 +82,40 @@ void QParameterizableObject::clear(QQmlListProperty<QObject> *p) object->clearChildren(); } +class QParameterizableObjectData: public QAbstractDeclarativeData +{ +public: + QParameterizableObjectData() + { + init(); + } + + static inline void init() { + static bool initialized = false; + if (!initialized) { + initialized = true; + QAbstractDeclarativeData::parentChanged = parentChanged; + } + } + + static void parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p); +}; + +Q_GLOBAL_STATIC(QParameterizableObjectData, parametrizableObjectData) + +QParameterizableObject::QParameterizableObject(QObject *parent) + : QObject(parent) +{ + QObjectPrivate::get(this)->declarativeData = parametrizableObjectData; +} + +void QParameterizableObjectData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p) +{ + Q_UNUSED(p) + Q_UNUSED(d) + QParameterizableObject *po = qobject_cast<QParameterizableObject *>(o); + if (po) + po->parentChanged(); +} + QT_END_NAMESPACE diff --git a/src/location/declarativemaps/qparameterizableobject_p.h b/src/location/declarativemaps/qparameterizableobject_p.h index e450c6ec..cf393aee 100644 --- a/src/location/declarativemaps/qparameterizableobject_p.h +++ b/src/location/declarativemaps/qparameterizableobject_p.h @@ -58,6 +58,7 @@ class QGeoMapParameter; class Q_LOCATION_PRIVATE_EXPORT QParameterizableObject : public QObject { Q_OBJECT + Q_PROPERTY(QObject *parent READ parent NOTIFY parentChanged DESIGNABLE false FINAL) Q_PROPERTY(QQmlListProperty<QObject> quickChildren READ declarativeChildren DESIGNABLE false) Q_CLASSINFO("DefaultProperty", "quickChildren") @@ -76,6 +77,9 @@ public: return res; } +Q_SIGNALS: + void parentChanged(); + protected: virtual void appendChild(QObject *v); virtual void clearChildren(); diff --git a/src/location/labs/qmapcircleobject.cpp b/src/location/labs/qmapcircleobject.cpp index 5f0db29d..fdfc834d 100644 --- a/src/location/labs/qmapcircleobject.cpp +++ b/src/location/labs/qmapcircleobject.cpp @@ -250,7 +250,7 @@ QColor QMapCircleObject::color() const QDeclarativeMapLineProperties *QMapCircleObject::border() { if (!m_border) { - m_border = new QDeclarativeMapLineProperties; + m_border = new QDeclarativeMapLineProperties(this); connect(m_border, &QDeclarativeMapLineProperties::colorChanged, this, [this](const QColor &color){ static_cast<QMapCircleObjectPrivate*>(d_ptr.data())->setBorderColor(color); }); diff --git a/src/location/labs/qmapobjectview.cpp b/src/location/labs/qmapobjectview.cpp index 8cbf8ded..54d384fb 100644 --- a/src/location/labs/qmapobjectview.cpp +++ b/src/location/labs/qmapobjectview.cpp @@ -339,8 +339,10 @@ void QMapObjectView::modelUpdated(const QQmlChangeSet &changeSet, bool reset) for (int idx = c.start(); idx < c.end(); idx++) { m_instantiatedMapObjects.insert(idx, nullptr); QGeoMapObject *mo = qobject_cast<QGeoMapObject *>(m_delegateModel->object(idx, incubationMode)); - if (mo) // if not, a createdItem signal will be emitted later, else it has been emitted already while createBlocker is in effect. + if (mo) {// if not, a createdItem signal will be emitted later, else it has been emitted already while createBlocker is in effect. + mo->setParent(this); addMapObjectToMap(mo, idx); + } } } } @@ -395,10 +397,12 @@ void QMapObjectView::createdItem(int index, QObject * /*object*/) // or else, it will be destroyed exiting this scope QGeoMapObject *mo = nullptr; mo = qobject_cast<QGeoMapObject *>(m_delegateModel->object(index, incubationMode)); - if (mo) + if (mo) { + mo->setParent(this); addMapObjectToMap(mo, index); - else + } else { qWarning() << "QQmlDelegateModel::object called in createdItem for " << index << " produced a null object"; + } } @@ -436,7 +440,11 @@ void QMapObjectView::setMap(QGeoMap *map) // Map was set, now it has ben re-set to NULL flushDelegateModel(); flushUserAddedMapObjects(); + bool oldVisible = d_ptr->m_visible; + bool oldCmponentCompleted = d_ptr->m_componentCompleted; d_ptr = new QMapObjectViewPrivateDefault(*d); + d_ptr->m_componentCompleted = oldCmponentCompleted; + d_ptr->setVisible(oldVisible); } else if (d->m_componentCompleted) { // Map was null, now it's set AND delegateModel is already complete. // some delegates may have been incubated but not added to the map. diff --git a/src/location/labs/qmappolygonobject.cpp b/src/location/labs/qmappolygonobject.cpp index 6ccba748..5a8ce228 100644 --- a/src/location/labs/qmappolygonobject.cpp +++ b/src/location/labs/qmappolygonobject.cpp @@ -250,7 +250,7 @@ QColor QMapPolygonObject::color() const QDeclarativeMapLineProperties *QMapPolygonObject::border() { if (!m_border) { - m_border = new QDeclarativeMapLineProperties; + m_border = new QDeclarativeMapLineProperties(this); connect(m_border, &QDeclarativeMapLineProperties::colorChanged, this, [this](const QColor &color){ static_cast<QMapPolygonObjectPrivate*>(d_ptr.data())->setBorderColor(color); }); diff --git a/src/location/labs/qmappolygonobject_p.h b/src/location/labs/qmappolygonobject_p.h index 03eef587..e924afab 100644 --- a/src/location/labs/qmappolygonobject_p.h +++ b/src/location/labs/qmappolygonobject_p.h @@ -82,7 +82,7 @@ signals: void colorChanged(); protected: - QDeclarativeMapLineProperties *m_border; + QDeclarativeMapLineProperties *m_border = nullptr; }; QT_END_NAMESPACE diff --git a/src/location/labs/qmappolygonobject_p_p.h b/src/location/labs/qmappolygonobject_p_p.h index 767765df..52bbaf4c 100644 --- a/src/location/labs/qmappolygonobject_p_p.h +++ b/src/location/labs/qmappolygonobject_p_p.h @@ -103,7 +103,7 @@ public: public: QGeoPolygon m_path; // small overhead compared to plain QList<QGeoCoordinate> - QColor m_borderColor; + QColor m_borderColor = Qt::transparent; QColor m_fillColor = Qt::transparent; qreal m_borderWidth = 0; diff --git a/src/location/labs/qmappolylineobject.cpp b/src/location/labs/qmappolylineobject.cpp index c6d3cdaf..81390d7c 100644 --- a/src/location/labs/qmappolylineobject.cpp +++ b/src/location/labs/qmappolylineobject.cpp @@ -191,7 +191,7 @@ QVariantList QMapPolylineObject::path() const QDeclarativeMapLineProperties *QMapPolylineObject::border() { if (!m_border) { - m_border = new QDeclarativeMapLineProperties; + m_border = new QDeclarativeMapLineProperties(this); connect(m_border, &QDeclarativeMapLineProperties::colorChanged, this, [this](const QColor &color){ static_cast<QMapPolylineObjectPrivate*>(d_ptr.data())->setColor(color); }); diff --git a/src/location/maps/qgeotiledmapscene.cpp b/src/location/maps/qgeotiledmapscene.cpp index a8bee156..18d92b00 100644 --- a/src/location/maps/qgeotiledmapscene.cpp +++ b/src/location/maps/qgeotiledmapscene.cpp @@ -515,7 +515,7 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root, bool ok = d->buildGeometry(it.key(), node, overzooming) && qgeotiledmapscene_isTileInViewport(node->rect(), root->matrix(), straight); - QSGNode::DirtyState dirtyBits = 0; + QSGNode::DirtyState dirtyBits = {}; if (!ok) { #ifdef QT_LOCATION_DEBUG diff --git a/src/plugins/geoservices/esri/geocodereply_esri.cpp b/src/plugins/geoservices/esri/geocodereply_esri.cpp index eca3def1..05f941d1 100644 --- a/src/plugins/geoservices/esri/geocodereply_esri.cpp +++ b/src/plugins/geoservices/esri/geocodereply_esri.cpp @@ -84,7 +84,7 @@ void GeoCodeReplyEsri::networkReplyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); diff --git a/src/plugins/geoservices/esri/georoutereply_esri.cpp b/src/plugins/geoservices/esri/georoutereply_esri.cpp index a47db6fb..78e14a9b 100644 --- a/src/plugins/geoservices/esri/georoutereply_esri.cpp +++ b/src/plugins/geoservices/esri/georoutereply_esri.cpp @@ -70,7 +70,7 @@ void GeoRouteReplyEsri::networkReplyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); diff --git a/src/plugins/geoservices/esri/geotiledmapreply_esri.cpp b/src/plugins/geoservices/esri/geotiledmapreply_esri.cpp index 78f6c69a..2f4016a9 100644 --- a/src/plugins/geoservices/esri/geotiledmapreply_esri.cpp +++ b/src/plugins/geoservices/esri/geotiledmapreply_esri.cpp @@ -71,7 +71,7 @@ void GeoTiledMapReplyEsri::networkReplyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QByteArray const& imageData = reply->readAll(); diff --git a/src/plugins/geoservices/esri/placesearchreply_esri.cpp b/src/plugins/geoservices/esri/placesearchreply_esri.cpp index a5a3585a..b674c136 100644 --- a/src/plugins/geoservices/esri/placesearchreply_esri.cpp +++ b/src/plugins/geoservices/esri/placesearchreply_esri.cpp @@ -109,7 +109,7 @@ void PlaceSearchReplyEsri::replyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); diff --git a/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp b/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp index bb84b531..7e94e6e0 100644 --- a/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp @@ -76,7 +76,7 @@ void QGeoCodeReplyMapbox::onNetworkReplyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QList<QGeoLocation> locations; diff --git a/src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp b/src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp index 4b60231d..c10aba19 100644 --- a/src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp @@ -61,7 +61,7 @@ void QGeoMapReplyMapbox::networkReplyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; setMapImageData(reply->readAll()); diff --git a/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp b/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp index 86da24ab..f10b0086 100644 --- a/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp @@ -116,7 +116,7 @@ void QGeoRouteReplyMapbox::networkReplyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QGeoRoutingManagerEngineMapbox *engine = qobject_cast<QGeoRoutingManagerEngineMapbox *>(parent()); diff --git a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp index 8d34d2ec..7284b67a 100644 --- a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp +++ b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp @@ -167,7 +167,7 @@ void QPlaceSearchReplyMapbox::onReplyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; const QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); diff --git a/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp b/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp index 8c0bfdc1..95296172 100644 --- a/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp +++ b/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp @@ -86,7 +86,7 @@ void QPlaceSearchSuggestionReplyMapbox::onReplyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); diff --git a/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp index f67fa5bb..196b68d3 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp @@ -81,7 +81,7 @@ void QPlaceContentReplyImpl::replyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); diff --git a/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp index 1e7f2d2f..677efddc 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp @@ -118,7 +118,7 @@ void QPlaceDetailsReplyImpl::replyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyhere.cpp b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyhere.cpp index 28aa930f..49574084 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyhere.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyhere.cpp @@ -87,7 +87,7 @@ void QPlaceSearchReplyHere::replyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp index 9882545d..236af184 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp @@ -77,7 +77,7 @@ void QPlaceSearchSuggestionReplyImpl::replyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); diff --git a/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp b/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp index 2a8549ff..2b302a76 100644 --- a/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp @@ -83,7 +83,7 @@ void QGeoCodeReplyNokia::networkFinished() QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QGeoCodeJsonParser *parser = new QGeoCodeJsonParser; // QRunnable, autoDelete = true. diff --git a/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp b/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp index 6e1a1e85..1ae32004 100644 --- a/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp @@ -70,7 +70,7 @@ void QGeoMapReplyNokia::networkFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; setMapImageData(reply->readAll()); diff --git a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp index 941a0200..6aed85cc 100644 --- a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp @@ -80,8 +80,8 @@ void QGeoRouteReplyNokia::networkFinished() QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError - && reply->error() != QNetworkReply::UnknownContentError) { + if (reply->networkError() != QNetworkReply::NoError + && reply->networkError() != QNetworkReply::UnknownContentError) { return; } diff --git a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp index d07a93ba..2e16a5d8 100644 --- a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp @@ -247,7 +247,7 @@ QString QGeoTileFetcherNokia::applicationId() const void QGeoTileFetcherNokia::copyrightsFetched() { - if (m_engineNokia && m_copyrightsReply->error() == QNetworkReply::NoError) { + if (m_engineNokia && m_copyrightsReply->networkError() == QNetworkReply::NoError) { QMetaObject::invokeMethod(m_engineNokia.data(), "loadCopyrightsDescriptorsFromJson", Qt::QueuedConnection, @@ -259,7 +259,7 @@ void QGeoTileFetcherNokia::copyrightsFetched() void QGeoTileFetcherNokia::versionFetched() { - if (m_engineNokia && m_versionReply->error() == QNetworkReply::NoError) { + if (m_engineNokia && m_versionReply->networkError() == QNetworkReply::NoError) { QMetaObject::invokeMethod(m_engineNokia.data(), "parseNewVersionInfo", Qt::QueuedConnection, @@ -288,7 +288,7 @@ void QGeoTileFetcherNokia::fetchCopyrightsData() QNetworkRequest netRequest((QUrl(copyrightUrl))); m_copyrightsReply = m_networkManager->get(netRequest); - if (m_copyrightsReply->error() != QNetworkReply::NoError) { + if (m_copyrightsReply->networkError() != QNetworkReply::NoError) { qWarning() << __FUNCTION__ << m_copyrightsReply->errorString(); m_copyrightsReply->deleteLater(); return; @@ -321,7 +321,7 @@ void QGeoTileFetcherNokia::fetchVersionData() QNetworkRequest netRequest((QUrl(versionUrl))); m_versionReply = m_networkManager->get(netRequest); - if (m_versionReply->error() != QNetworkReply::NoError) { + if (m_versionReply->networkError() != QNetworkReply::NoError) { qWarning() << __FUNCTION__ << m_versionReply->errorString(); m_versionReply->deleteLater(); return; diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp index 3b507ff2..acf43a01 100644 --- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp +++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp @@ -777,7 +777,7 @@ void QPlaceManagerEngineNokiaV2::categoryReplyFinished() QString categoryId; - if (reply->error() == QNetworkReply::NoError) { + if (reply->networkError() == QNetworkReply::NoError) { QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); if (!document.isObject()) { if (m_categoryReply) { diff --git a/src/plugins/geoservices/osm/qgeocodereplyosm.cpp b/src/plugins/geoservices/osm/qgeocodereplyosm.cpp index b4733d69..145a26ca 100644 --- a/src/plugins/geoservices/osm/qgeocodereplyosm.cpp +++ b/src/plugins/geoservices/osm/qgeocodereplyosm.cpp @@ -129,7 +129,7 @@ void QGeoCodeReplyOsm::networkReplyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QList<QGeoLocation> locations; diff --git a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp index a06f91f3..b83d9015 100644 --- a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp +++ b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp @@ -68,7 +68,7 @@ void QGeoMapReplyOsm::networkReplyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) // Already handled in networkReplyError + if (reply->networkError() != QNetworkReply::NoError) // Already handled in networkReplyError return; QByteArray a = reply->readAll(); diff --git a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp index e60dc068..45e6b2c3 100644 --- a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp +++ b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp @@ -66,7 +66,7 @@ void QGeoRouteReplyOsm::networkReplyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QGeoRoutingManagerEngineOsm *engine = qobject_cast<QGeoRoutingManagerEngineOsm *>(parent()); diff --git a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp index 1eedddb1..13b9f47e 100644 --- a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp +++ b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp @@ -383,8 +383,8 @@ void TileProvider::onNetworkReplyFinished() QObject errorEmitter; QMetaObject::Connection errorEmitterConnection = connect(&errorEmitter, &QObject::destroyed, [this](){ this->resolutionError(this); }); - if (reply->error() != QNetworkReply::NoError) { - handleError(reply->error()); + if (reply->networkError() != QNetworkReply::NoError) { + handleError(reply->networkError()); return; } m_status = Invalid; diff --git a/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp b/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp index 366ff852..ba6eb81c 100644 --- a/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp +++ b/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp @@ -99,7 +99,7 @@ void QPlaceSearchReplyOsm::replyFinished() QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); - if (reply->error() != QNetworkReply::NoError) + if (reply->networkError() != QNetworkReply::NoError) return; QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); diff --git a/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp b/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp index bbc70f0a..414d2f34 100644 --- a/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp +++ b/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp @@ -437,7 +437,7 @@ QList<QGeoAreaMonitorInfo> QGeoAreaMonitorPolling::activeMonitors(const QGeoShap QGeoAreaMonitorSource::AreaMonitorFeatures QGeoAreaMonitorPolling::supportedAreaMonitorFeatures() const { - return 0; + return {}; } void QGeoAreaMonitorPolling::connectNotify(const QMetaMethod &/*signal*/) diff --git a/src/positioning/qgeopositioninfosource.cpp b/src/positioning/qgeopositioninfosource.cpp index 0610bd79..1f9abec1 100644 --- a/src/positioning/qgeopositioninfosource.cpp +++ b/src/positioning/qgeopositioninfosource.cpp @@ -206,7 +206,7 @@ QGeoPositionInfoSource::QGeoPositionInfoSource(QObject *parent) { qRegisterMetaType<QGeoPositionInfo>(); d->interval = 0; - d->methods = 0; + d->methods = {}; } /*! diff --git a/src/positioningquick/qdeclarativepositionsource.cpp b/src/positioningquick/qdeclarativepositionsource.cpp index 6e042d9f..d6c62147 100644 --- a/src/positioningquick/qdeclarativepositionsource.cpp +++ b/src/positioningquick/qdeclarativepositionsource.cpp @@ -404,8 +404,8 @@ void QDeclarativePositionSource::socketConnected() */ void QDeclarativePositionSource::socketError(QAbstractSocket::SocketError error) { - delete m_nmeaSocket; - m_nmeaSocket = 0; + m_nmeaSocket->deleteLater(); + m_nmeaSocket = nullptr; switch (error) { case QAbstractSocket::UnknownSocketError: |