From db8e4340d65eea4d82b49a67d525d33cdb0478fc Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Mon, 21 Aug 2017 14:38:29 +0200 Subject: Fix QDeclarativeGeoMap::populateMap duplicating items Since apparently children() and childItems() do not necessarily return disjoint sets, concatenating the two lists did, in some cases, cause duplicated items in the map. This patch resorts to uniting sets to remove the duplicates. Change-Id: I07ef19a2fdff65429eb65d92be278d7c02ac1999 Reviewed-by: BogDan Vatra --- src/location/declarativemaps/qdeclarativegeomap.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp index dedb590e..2ed482e3 100644 --- a/src/location/declarativemaps/qdeclarativegeomap.cpp +++ b/src/location/declarativemaps/qdeclarativegeomap.cpp @@ -539,26 +539,26 @@ QQuickGeoMapGestureArea *QDeclarativeGeoMap::gesture() */ void QDeclarativeGeoMap::populateMap() { - QObjectList kids = children(); - QList quickKids = childItems(); - for (int i=0; i < quickKids.count(); ++i) - kids.append(quickKids.at(i)); + QSet kids = children().toSet(); + const QList quickKids = childItems(); + for (QQuickItem *ite: quickKids) + kids.insert(ite); - for (int i = 0; i < kids.size(); ++i) { + for (QObject *k : qAsConst(kids)) { // dispatch items appropriately - QDeclarativeGeoMapItemView *mapView = qobject_cast(kids.at(i)); + QDeclarativeGeoMapItemView *mapView = qobject_cast(k); if (mapView) { m_mapViews.append(mapView); setupMapView(mapView); continue; } - QDeclarativeGeoMapItemBase *mapItem = qobject_cast(kids.at(i)); + QDeclarativeGeoMapItemBase *mapItem = qobject_cast(k); if (mapItem) { addMapItem(mapItem); continue; } // Allow to add to the map Map items contained inside a parent QQuickItem, but only those at one level of nesting. - QDeclarativeGeoMapItemGroup *itemGroup = qobject_cast(kids.at(i)); + QDeclarativeGeoMapItemGroup *itemGroup = qobject_cast(k); if (itemGroup) { addMapItemGroup(itemGroup); continue; -- cgit v1.2.1