diff options
-rw-r--r-- | src/location/declarativemaps/qparameterizableobject.cpp | 13 | ||||
-rw-r--r-- | src/location/declarativemaps/qparameterizableobject_p.h | 2 | ||||
-rw-r--r-- | src/location/labs/qmapobjectview.cpp | 4 |
3 files changed, 9 insertions, 10 deletions
diff --git a/src/location/declarativemaps/qparameterizableobject.cpp b/src/location/declarativemaps/qparameterizableobject.cpp index 25c535e0..b1e588e6 100644 --- a/src/location/declarativemaps/qparameterizableobject.cpp +++ b/src/location/declarativemaps/qparameterizableobject.cpp @@ -94,11 +94,9 @@ public: 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) @@ -109,13 +107,12 @@ QParameterizableObject::QParameterizableObject(QObject *parent) QObjectPrivate::get(this)->declarativeData = parametrizableObjectData; } -void QParameterizableObjectData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p) +void QParameterizableObject::setParentAndNotify(QObject *parent) { - Q_UNUSED(p); - Q_UNUSED(d); - QParameterizableObject *po = qobject_cast<QParameterizableObject *>(o); - if (po) - po->parentChanged(); + QObject *oldParent = this->parent(); + QObject::setParent(parent); + if (parent != oldParent) + emit parentChanged(); } QT_END_NAMESPACE diff --git a/src/location/declarativemaps/qparameterizableobject_p.h b/src/location/declarativemaps/qparameterizableobject_p.h index cf393aee..21a096e0 100644 --- a/src/location/declarativemaps/qparameterizableobject_p.h +++ b/src/location/declarativemaps/qparameterizableobject_p.h @@ -77,6 +77,8 @@ public: return res; } + void setParentAndNotify(QObject *parent); + Q_SIGNALS: void parentChanged(); diff --git a/src/location/labs/qmapobjectview.cpp b/src/location/labs/qmapobjectview.cpp index a5143c54..a015d425 100644 --- a/src/location/labs/qmapobjectview.cpp +++ b/src/location/labs/qmapobjectview.cpp @@ -340,7 +340,7 @@ void QMapObjectView::modelUpdated(const QQmlChangeSet &changeSet, bool reset) 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. - mo->setParent(this); + mo->setParentAndNotify(this); addMapObjectToMap(mo, idx); } } @@ -398,7 +398,7 @@ void QMapObjectView::createdItem(int index, QObject * /*object*/) QGeoMapObject *mo = nullptr; mo = qobject_cast<QGeoMapObject *>(m_delegateModel->object(index, incubationMode)); if (mo) { - mo->setParent(this); + mo->setParentAndNotify(this); addMapObjectToMap(mo, index); } else { qWarning() << "QQmlDelegateModel::object called in createdItem for " << index << " produced a null object"; |