summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-02-07 12:48:44 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-02-07 16:43:10 +0000
commitd80a98e987390a5a355a8ed20c4e713c43d148dc (patch)
tree5996732b95a11d477aec898daeee841c9892b3d0
parent6962059388da2820fc6d0b6947243f8d8c7d4025 (diff)
downloadqtlocation-d80a98e987390a5a355a8ed20c4e713c43d148dc.tar.gz
Let QGeoMap::createMapObjectImplementation set the implementation
This prevents a sort of "call super" antipattern, where each specific createMapObjectImplementation have to call the setImplementation internally. Change-Id: I0babe89a3a01728e95209cf832f4debc3d8af158 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
-rw-r--r--src/location/declarativemaps/qgeomapobject.cpp4
-rw-r--r--src/location/declarativemaps/qgeomapobject_p.h2
-rw-r--r--src/location/maps/qgeomap.cpp11
-rw-r--r--src/location/maps/qgeomap_p_p.h3
4 files changed, 13 insertions, 7 deletions
diff --git a/src/location/declarativemaps/qgeomapobject.cpp b/src/location/declarativemaps/qgeomapobject.cpp
index 3c8fbcff..9d94900f 100644
--- a/src/location/declarativemaps/qgeomapobject.cpp
+++ b/src/location/declarativemaps/qgeomapobject.cpp
@@ -101,11 +101,11 @@ QGeoMapObjectPrivate *QGeoMapObject::implementation() const
return d_ptr.data();
}
-bool QGeoMapObject::setImplementation(QGeoMapObjectPrivate *pimpl)
+bool QGeoMapObject::setImplementation(const QExplicitlySharedDataPointer<QGeoMapObjectPrivate> &pimpl)
{
if (d_ptr->type() != pimpl->type())
return false;
- d_ptr = QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(pimpl);
+ d_ptr = pimpl;
return true;
}
diff --git a/src/location/declarativemaps/qgeomapobject_p.h b/src/location/declarativemaps/qgeomapobject_p.h
index 3c18cc8f..669a79f3 100644
--- a/src/location/declarativemaps/qgeomapobject_p.h
+++ b/src/location/declarativemaps/qgeomapobject_p.h
@@ -94,7 +94,7 @@ public:
Features features() const;
QGeoMapObjectPrivate *implementation() const;
- bool setImplementation(QGeoMapObjectPrivate *pimpl);
+ bool setImplementation(const QExplicitlySharedDataPointer<QGeoMapObjectPrivate> &pimpl);
bool implemented() const;
bool visible() const;
diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp
index 4ac36fed..a346786a 100644
--- a/src/location/maps/qgeomap.cpp
+++ b/src/location/maps/qgeomap.cpp
@@ -40,6 +40,7 @@
#include "qgeomappingmanagerengine_p.h"
#include "qdeclarativegeomapitembase_p.h"
#include "qgeomapobject_p.h"
+#include "qgeomapobject_p_p.h"
#include <QDebug>
QT_BEGIN_NAMESPACE
@@ -280,7 +281,11 @@ void QGeoMap::clearMapItems()
bool QGeoMap::createMapObjectImplementation(QGeoMapObject *obj)
{
Q_D(QGeoMap);
- return d->createMapObjectImplementation(obj);
+ QExplicitlySharedDataPointer<QGeoMapObjectPrivate> pimpl =
+ QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(d->createMapObjectImplementation(obj));
+ if (pimpl.constData())
+ return obj->setImplementation(pimpl);
+ return false;
}
QList<QGeoMapObject *> QGeoMap::mapObjects() const
@@ -365,10 +370,10 @@ void QGeoMapPrivate::removeMapItem(QDeclarativeGeoMapItemBase *item)
Q_UNUSED(item)
}
-bool QGeoMapPrivate::createMapObjectImplementation(QGeoMapObject *obj)
+QGeoMapObjectPrivate *QGeoMapPrivate::createMapObjectImplementation(QGeoMapObject *obj)
{
Q_UNUSED(obj)
- return false;
+ return nullptr;
}
QList<QGeoMapObject *> QGeoMapPrivate::mapObjects() const
diff --git a/src/location/maps/qgeomap_p_p.h b/src/location/maps/qgeomap_p_p.h
index d6ab40b6..615571d1 100644
--- a/src/location/maps/qgeomap_p_p.h
+++ b/src/location/maps/qgeomap_p_p.h
@@ -66,6 +66,7 @@ class QGeoMap;
class QGeoMapController;
class QGeoMapParameter;
class QDeclarativeGeoMapItemBase;
+class QGeoMapObjectPrivate;
class Q_LOCATION_PRIVATE_EXPORT QGeoMapPrivate : public QObjectPrivate
{
@@ -89,7 +90,7 @@ protected:
virtual void addMapItem(QDeclarativeGeoMapItemBase *item);
virtual void removeMapItem(QDeclarativeGeoMapItemBase *item);
- virtual bool createMapObjectImplementation(QGeoMapObject *obj);
+ virtual QGeoMapObjectPrivate *createMapObjectImplementation(QGeoMapObject *obj);
virtual QList<QGeoMapObject *> mapObjects() const;
virtual void changeViewportSize(const QSize &size) = 0; // called by QGeoMap::setSize()