diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-08-21 14:38:29 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-08-23 10:43:09 +0000 |
commit | db8e4340d65eea4d82b49a67d525d33cdb0478fc (patch) | |
tree | a8fc82090f8c8ca97425723d958d5d52b0bf780d /src/location | |
parent | 47e2c461d517a6bb2fe663f752f3c7dd72c63357 (diff) | |
download | qtlocation-db8e4340d65eea4d82b49a67d525d33cdb0478fc.tar.gz |
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 <bogdan@kdab.com>
Diffstat (limited to 'src/location')
-rw-r--r-- | src/location/declarativemaps/qdeclarativegeomap.cpp | 16 |
1 files 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<QQuickItem *> quickKids = childItems(); - for (int i=0; i < quickKids.count(); ++i) - kids.append(quickKids.at(i)); + QSet<QObject *> kids = children().toSet(); + const QList<QQuickItem *> 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<QDeclarativeGeoMapItemView *>(kids.at(i)); + QDeclarativeGeoMapItemView *mapView = qobject_cast<QDeclarativeGeoMapItemView *>(k); if (mapView) { m_mapViews.append(mapView); setupMapView(mapView); continue; } - QDeclarativeGeoMapItemBase *mapItem = qobject_cast<QDeclarativeGeoMapItemBase *>(kids.at(i)); + QDeclarativeGeoMapItemBase *mapItem = qobject_cast<QDeclarativeGeoMapItemBase *>(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<QDeclarativeGeoMapItemGroup *>(kids.at(i)); + QDeclarativeGeoMapItemGroup *itemGroup = qobject_cast<QDeclarativeGeoMapItemGroup *>(k); if (itemGroup) { addMapItemGroup(itemGroup); continue; |