summaryrefslogtreecommitdiff
path: root/src/location/declarativemaps/qdeclarativegeomap.cpp
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-06-09 16:26:56 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-06-18 08:04:43 +0000
commitc0683791e467e75067ec1948952528a1ba998710 (patch)
treee92035aaee39c4248bfda0cafc09d739c3483938 /src/location/declarativemaps/qdeclarativegeomap.cpp
parentf05bcda6bea40c85edafc8b898629804106ca5e8 (diff)
downloadqtlocation-c0683791e467e75067ec1948952528a1ba998710.tar.gz
Fix add/removeMapItemGroup not checking if the item is added to a map
Currently these methods aren't checking if a group is already added to another map. This patch fixes it. Change-Id: I58a5e633b44abfcae5c362f8e97d4c6706869ac5 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location/declarativemaps/qdeclarativegeomap.cpp')
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 1f2886d8..f5d2bdb5 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -1849,13 +1849,11 @@ void QDeclarativeGeoMap::clearMapItems()
*/
void QDeclarativeGeoMap::addMapItemGroup(QDeclarativeGeoMapItemGroup *itemGroup)
{
- if (!itemGroup)
+ if (!itemGroup || itemGroup->quickMap()) // || Already added to some map
return;
+ itemGroup->setQuickMap(this);
QPointer<QDeclarativeGeoMapItemGroup> g(itemGroup);
- if (m_mapItemGroups.contains(g))
- return;
-
m_mapItemGroups.append(g);
const QList<QQuickItem *> quickKids = g->childItems();
for (auto c: quickKids) {
@@ -1877,7 +1875,7 @@ void QDeclarativeGeoMap::addMapItemGroup(QDeclarativeGeoMapItemGroup *itemGroup)
*/
void QDeclarativeGeoMap::removeMapItemGroup(QDeclarativeGeoMapItemGroup *itemGroup)
{
- if (!itemGroup)
+ if (!itemGroup || itemGroup->quickMap() != this) // cant remove an itemGroup added to another map
return;
QPointer<QDeclarativeGeoMapItemGroup> g(itemGroup);
@@ -1890,6 +1888,7 @@ void QDeclarativeGeoMap::removeMapItemGroup(QDeclarativeGeoMapItemGroup *itemGro
if (mapItem)
removeMapItem(mapItem);
}
+ itemGroup->setQuickMap(nullptr);
itemGroup->setParentItem(0);
}