summaryrefslogtreecommitdiff
path: root/src/location
diff options
context:
space:
mode:
Diffstat (limited to 'src/location')
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapquickitem.cpp5
-rw-r--r--src/location/labs/qdeclarativenavigator.cpp18
-rw-r--r--src/location/labs/qmapobjectview.cpp28
-rw-r--r--src/location/labs/qmapobjectview_p.h3
4 files changed, 42 insertions, 12 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
index 8c71e7be..5f9ecc8a 100644
--- a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
@@ -249,9 +249,10 @@ QGeoCoordinate QDeclarativeGeoMapQuickItem::coordinate()
*/
void QDeclarativeGeoMapQuickItem::setSourceItem(QQuickItem *sourceItem)
{
- if (sourceItem_.data() == sourceItem)
+ QQuickItem *item = qobject_cast<QQuickItem *>(sourceItem); // Workaround for QTBUG-72930
+ if (sourceItem_.data() == item)
return;
- sourceItem_ = sourceItem;
+ sourceItem_ = item;
polishAndUpdate();
emit sourceItemChanged();
}
diff --git a/src/location/labs/qdeclarativenavigator.cpp b/src/location/labs/qdeclarativenavigator.cpp
index 0bf5035f..5b98f27f 100644
--- a/src/location/labs/qdeclarativenavigator.cpp
+++ b/src/location/labs/qdeclarativenavigator.cpp
@@ -43,6 +43,24 @@
QT_BEGIN_NAMESPACE
/*!
+ \qmlmodule Qt.labs.location 1.0
+ \title Qt Labs Location QML Types
+ \ingroup qmlmodules
+ \brief Provides experimental QtLocation QML types, such as \l Navigator and
+ various map objects types (not to be confused with map items).
+
+ To use this module, import the module with the following line:
+
+ \code
+ import Qt.labs.location 1.0
+ \endcode
+
+ \note These types are experimental and subject to source-incompatible changes from one
+ Qt minor release to the next, until they are ready to be moved to the stable QtLocation QML
+ module.
+*/
+
+/*!
\qmltype Navigator
\instantiates QDeclarativeNavigator
\inqmlmodule Qt.labs.location
diff --git a/src/location/labs/qmapobjectview.cpp b/src/location/labs/qmapobjectview.cpp
index 2ffc27bc..fc583415 100644
--- a/src/location/labs/qmapobjectview.cpp
+++ b/src/location/labs/qmapobjectview.cpp
@@ -153,8 +153,8 @@ void QMapObjectView::classBegin()
QQmlInstanceModel *model = m_delegateModel;
connect(model, &QQmlInstanceModel::modelUpdated, this, &QMapObjectView::modelUpdated);
connect(model, &QQmlInstanceModel::createdItem, this, &QMapObjectView::createdItem);
- connect(model, &QQmlInstanceModel::destroyingItem, this, &QMapObjectView::destroyingItem);
- connect(model, &QQmlInstanceModel::initItem, this, &QMapObjectView::initItem);
+// connect(model, &QQmlInstanceModel::destroyingItem, this, &QMapObjectView::destroyingItem);
+// connect(model, &QQmlInstanceModel::initItem, this, &QMapObjectView::initItem);
}
void QMapObjectView::componentComplete()
@@ -278,11 +278,12 @@ void QMapObjectView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
}
}
+ QBoolBlocker createBlocker(m_creatingObject, true);
for (const QQmlChangeSet::Change &c: changeSet.inserts()) {
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.
+ if (mo) // if not, a createdItem signal will be emitted later, else it has been emitted already while createBlocker is in effect.
addMapObjectToMap(mo, idx);
}
}
@@ -311,12 +312,17 @@ void QMapObjectView::removeMapObjectFromMap(int index)
{
if (index >= 0 && index < m_instantiatedMapObjects.size()) {
QGeoMapObject *mo = m_instantiatedMapObjects.takeAt(index);
- if (!mo) {
- m_delegateModel->cancel(index);
+ if (!mo)
return;
- }
+
mo->setMap(nullptr);
- m_delegateModel->release(mo);
+ QQmlInstanceModel::ReleaseFlags releaseStatus = m_delegateModel->release(mo);
+#ifdef QT_DEBUG
+ if (releaseStatus == QQmlInstanceModel::Referenced)
+ qWarning() << "object "<<mo<<" still referenced";
+#else
+ Q_UNUSED(releaseStatus)
+#endif
}
}
@@ -324,8 +330,10 @@ void QMapObjectView::removeMapObjectFromMap(int index)
// for explanation on when createdItem is emitted.
void QMapObjectView::createdItem(int index, QObject * /*object*/)
{
- if (m_instantiatedMapObjects.at(index))
- return; // The first call to object() apparently returned a valid item. Don't call it again.
+ if (m_creatingObject) {
+ // see QDeclarativeGeoMapItemView::createdItem
+ return;
+ }
// If here, according to the documentation above, object() should be called again for index,
// or else, it will be destroyed exiting this scope
@@ -333,6 +341,8 @@ void QMapObjectView::createdItem(int index, QObject * /*object*/)
mo = qobject_cast<QGeoMapObject *>(m_delegateModel->object(index, incubationMode));
if (mo)
addMapObjectToMap(mo, index);
+ else
+ qWarning() << "QQmlDelegateModel::object called in createdItem for " << index << " produced a null object";
}
diff --git a/src/location/labs/qmapobjectview_p.h b/src/location/labs/qmapobjectview_p.h
index 49b80883..76affced 100644
--- a/src/location/labs/qmapobjectview_p.h
+++ b/src/location/labs/qmapobjectview_p.h
@@ -107,8 +107,9 @@ protected:
QQmlComponent *m_delegate = nullptr;
QQmlDelegateModel *m_delegateModel = nullptr;
QVector<QPointer<QGeoMapObject>> m_instantiatedMapObjects;
- QVector<QPointer<QGeoMapObject>> m_pendingMapObjects;
+ QVector<QPointer<QGeoMapObject>> m_pendingMapObjects; // for items instantiated before the map is set
QVector<QPointer<QGeoMapObject>> m_userAddedMapObjects; // A third list containing the objects dynamically added through addMapObject
+ bool m_creatingObject = false;
};
QT_END_NAMESPACE