From 24273e2249082a904b326c16a1913bcef3a37367 Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Mon, 21 Jan 2019 15:50:52 +0100 Subject: Fix crash when removing items from MapboxGL maps Triggered by usage of a virtual method in superclass destructor. Change-Id: If99e523e42fd13686ae43c0083a74e1b68221fc7 Fixes: QTBUG-67638 Reviewed-by: Eskil Abrahamsen Blomfeldt (cherry picked from commit 1ac41150501d3c5cc4a9a6ed9c93729687666553) Reviewed-by: Paolo Angelelli --- src/location/declarativemaps/qdeclarativecirclemapitem.cpp | 6 +----- src/location/declarativemaps/qdeclarativecirclemapitem_p.h | 1 - src/location/declarativemaps/qdeclarativegeomapitembase.cpp | 5 +++++ src/location/declarativemaps/qdeclarativegeomapitembase_p.h | 4 +++- src/location/declarativemaps/qdeclarativegeomapquickitem.cpp | 6 +----- src/location/declarativemaps/qdeclarativegeomapquickitem_p.h | 1 - src/location/declarativemaps/qdeclarativepolygonmapitem.cpp | 6 +----- src/location/declarativemaps/qdeclarativepolygonmapitem_p.h | 1 - src/location/declarativemaps/qdeclarativepolylinemapitem.cpp | 6 +----- src/location/declarativemaps/qdeclarativepolylinemapitem_p.h | 1 - src/location/declarativemaps/qdeclarativerectanglemapitem.cpp | 6 +----- src/location/declarativemaps/qdeclarativerectanglemapitem_p.h | 1 - 12 files changed, 13 insertions(+), 31 deletions(-) diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp index 2727cc26..b3496816 100644 --- a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp +++ b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp @@ -327,6 +327,7 @@ QDeclarativeCircleMapItem::QDeclarativeCircleMapItem(QQuickItem *parent) : QDeclarativeGeoMapItemBase(parent), border_(this), color_(Qt::transparent), dirtyMaterial_(true), updatingGeometry_(false) { + m_itemType = QGeoMap::MapCircle; setFlag(ItemHasContents, true); QObject::connect(&border_, SIGNAL(colorChanged(QColor)), this, SLOT(markSourceDirtyAndUpdate())); @@ -624,11 +625,6 @@ void QDeclarativeCircleMapItem::setGeoShape(const QGeoShape &shape) emit radiusChanged(circle_.radius()); } -QGeoMap::ItemType QDeclarativeCircleMapItem::itemType() const -{ - return QGeoMap::MapCircle; -} - /*! \internal */ diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem_p.h b/src/location/declarativemaps/qdeclarativecirclemapitem_p.h index a5b92881..4b3f81c0 100644 --- a/src/location/declarativemaps/qdeclarativecirclemapitem_p.h +++ b/src/location/declarativemaps/qdeclarativecirclemapitem_p.h @@ -95,7 +95,6 @@ public: bool contains(const QPointF &point) const override; const QGeoShape &geoShape() const override; void setGeoShape(const QGeoShape &shape) override; - QGeoMap::ItemType itemType() const override; static bool crossEarthPole(const QGeoCoordinate ¢er, qreal distance); static void calculatePeripheralPoints(QList &path, const QGeoCoordinate ¢er, diff --git a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp index 7de6afb5..523655c0 100644 --- a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp +++ b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp @@ -281,6 +281,11 @@ QSGNode *QDeclarativeGeoMapItemBase::updateMapItemPaintNode(QSGNode *oldNode, Up return 0; } +QGeoMap::ItemType QDeclarativeGeoMapItemBase::itemType() const +{ + return m_itemType; +} + /*! \internal diff --git a/src/location/declarativemaps/qdeclarativegeomapitembase_p.h b/src/location/declarativemaps/qdeclarativegeomapitembase_p.h index 4eff32db..23fd1da6 100644 --- a/src/location/declarativemaps/qdeclarativegeomapitembase_p.h +++ b/src/location/declarativemaps/qdeclarativegeomapitembase_p.h @@ -99,7 +99,7 @@ public: QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); virtual QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *); - virtual QGeoMap::ItemType itemType() const = 0; + QGeoMap::ItemType itemType() const; qreal mapItemOpacity() const; void setParentGroup(QDeclarativeGeoMapItemGroup &parentGroup); @@ -119,6 +119,8 @@ protected: bool childMouseEventFilter(QQuickItem *item, QEvent *event); bool isPolishScheduled() const; + QGeoMap::ItemType m_itemType = QGeoMap::NoItem; + private Q_SLOTS: void baseCameraDataChanged(const QGeoCameraData &camera); void visibleAreaChanged(); diff --git a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp index 5f9ecc8a..f7409788 100644 --- a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp +++ b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp @@ -135,6 +135,7 @@ QDeclarativeGeoMapQuickItem::QDeclarativeGeoMapQuickItem(QQuickItem *parent) : QDeclarativeGeoMapItemBase(parent), zoomLevel_(0.0), mapAndSourceItemSet_(false), updatingGeometry_(false), matrix_(nullptr) { + m_itemType = QGeoMap::MapQuickItem; setFlag(ItemHasContents, true); opacityContainer_ = new QQuickItem(this); opacityContainer_->setParentItem(this); @@ -362,11 +363,6 @@ void QDeclarativeGeoMapQuickItem::setGeoShape(const QGeoShape &shape) } -QGeoMap::ItemType QDeclarativeGeoMapQuickItem::itemType() const -{ - return QGeoMap::MapQuickItem; -} - /*! \internal */ diff --git a/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h b/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h index a27a0bce..2663fdc6 100644 --- a/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h +++ b/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h @@ -98,7 +98,6 @@ public: const QGeoShape &geoShape() const override; void setGeoShape(const QGeoShape &shape) override; - QGeoMap::ItemType itemType() const override; Q_SIGNALS: void coordinateChanged(); diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp index f4cdc6bf..734e03ff 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp @@ -318,6 +318,7 @@ QDeclarativePolygonMapItem::QDeclarativePolygonMapItem(QQuickItem *parent) : QDeclarativeGeoMapItemBase(parent), border_(this), color_(Qt::transparent), dirtyMaterial_(true), updatingGeometry_(false) { + m_itemType = QGeoMap::MapPolygon; setFlag(ItemHasContents, true); QObject::connect(&border_, SIGNAL(colorChanged(QColor)), this, SLOT(markSourceDirtyAndUpdate())); @@ -619,11 +620,6 @@ void QDeclarativePolygonMapItem::setGeoShape(const QGeoShape &shape) emit pathChanged(); } -QGeoMap::ItemType QDeclarativePolygonMapItem::itemType() const -{ - return QGeoMap::MapPolygon; -} - /*! \internal */ diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h index 87d72307..810a8d35 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h @@ -108,7 +108,6 @@ public: bool contains(const QPointF &point) const override; const QGeoShape &geoShape() const override; void setGeoShape(const QGeoShape &shape) override; - QGeoMap::ItemType itemType() const override; Q_SIGNALS: void pathChanged(); diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp index 2fb3098d..189e8273 100644 --- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp @@ -738,6 +738,7 @@ bool QGeoMapPolylineGeometry::contains(const QPointF &point) const QDeclarativePolylineMapItem::QDeclarativePolylineMapItem(QQuickItem *parent) : QDeclarativeGeoMapItemBase(parent), line_(this), dirtyMaterial_(true), updatingGeometry_(false) { + m_itemType = QGeoMap::MapPolyline; setFlag(ItemHasContents, true); QObject::connect(&line_, SIGNAL(colorChanged(QColor)), this, SLOT(updateAfterLinePropertiesChanged())); @@ -1149,11 +1150,6 @@ void QDeclarativePolylineMapItem::setGeoShape(const QGeoShape &shape) emit pathChanged(); } -QGeoMap::ItemType QDeclarativePolylineMapItem::itemType() const -{ - return QGeoMap::MapPolyline; -} - ////////////////////////////////////////////////////////////////////// /*! diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h index 1105bb13..3aa0f96b 100644 --- a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h +++ b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h @@ -156,7 +156,6 @@ public: bool contains(const QPointF &point) const override; const QGeoShape &geoShape() const override; void setGeoShape(const QGeoShape &shape) override; - QGeoMap::ItemType itemType() const override; QDeclarativeMapLineProperties *line(); diff --git a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp index ba67ecad..74f95734 100644 --- a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp +++ b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp @@ -118,6 +118,7 @@ QDeclarativeRectangleMapItem::QDeclarativeRectangleMapItem(QQuickItem *parent) : QDeclarativeGeoMapItemBase(parent), border_(this), color_(Qt::transparent), dirtyMaterial_(true), updatingGeometry_(false) { + m_itemType = QGeoMap::MapRectangle; setFlag(ItemHasContents, true); QObject::connect(&border_, SIGNAL(colorChanged(QColor)), this, SLOT(markSourceDirtyAndUpdate())); @@ -370,11 +371,6 @@ void QDeclarativeRectangleMapItem::setGeoShape(const QGeoShape &shape) emit bottomRightChanged(rectangle_.bottomRight()); } -QGeoMap::ItemType QDeclarativeRectangleMapItem::itemType() const -{ - return QGeoMap::MapRectangle; -} - /*! \internal */ diff --git a/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h b/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h index e2ac2974..790b99d9 100644 --- a/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h +++ b/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h @@ -91,7 +91,6 @@ public: bool contains(const QPointF &point) const override; const QGeoShape &geoShape() const override; void setGeoShape(const QGeoShape &shape) override; - QGeoMap::ItemType itemType() const override; Q_SIGNALS: void topLeftChanged(const QGeoCoordinate &topLeft); -- cgit v1.2.1