From 9daf00ef519e3dbd061e64bfe13b2ca9bfab4e28 Mon Sep 17 00:00:00 2001 From: Paolo Angelelli <paolo.angelelli@qt.io> Date: Sat, 10 Feb 2018 17:18:33 +0100 Subject: [PATCH] Assign QGeoMapObjectPrivate::m_map after creating the new implementation Or else it will be null, as no copy constructor for QGeoMapPrivate is defined (and used). Change-Id: I6045ccd4ec15c775a6ae0f9c55107103dfe28e9e Reviewed-by: BogDan Vatra <bogdan@kdab.com> --- src/location/declarativemaps/qgeomapobject.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/location/declarativemaps/qgeomapobject.cpp b/src/location/declarativemaps/qgeomapobject.cpp index 9d94900f4..2e81afa9d 100644 --- a/src/location/declarativemaps/qgeomapobject.cpp +++ b/src/location/declarativemaps/qgeomapobject.cpp @@ -176,16 +176,28 @@ void QGeoMapObject::setMap(QGeoMap *map) if (d_ptr->m_map == map) return; - d_ptr->m_map = map; if (map) { + bool oldVisible = d_ptr->m_visible; + bool oldCmponentCompleted = d_ptr->m_componentCompleted; if (!map->createMapObjectImplementation(this)) qWarning() << "Unsupported type " << type(); // old implementation gets destroyed if/when d_ptr gets replaced + d_ptr->m_componentCompleted = oldCmponentCompleted; + d_ptr->setVisible(oldVisible); } + d_ptr->m_map = map; const QList<QGeoMapObject *> kids = geoMapObjectChildren(); for (auto kid : kids) kid->setMap(map); + + // Each subclass is in charge to do the equivalent of + // if (!map) { + // // Map was set, now it has ben re-set to NULL + // d_ptr = new QMapCircleObjectPrivateDefault(*d); + // // Old pimpl deleted implicitly by QExplicitlySharedDataPointer + // } + // After this method is called. } QGeoMap *QGeoMapObject::map() const -- GitLab