From e09d0e9351e237ad6c9d417c20a24469df743eca Mon Sep 17 00:00:00 2001
From: Paolo Angelelli <paolo.angelelli@qt.io>
Date: Mon, 12 Feb 2018 19:11:38 +0100
Subject: [PATCH] Fix crash calling Map.clearMapItems before Map is initialized

Task-number: QTBUG-66315
Change-Id: I18af392a00303b3b4c515c8f557e9c3fa09657eb
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
---
 src/location/declarativemaps/qdeclarativegeomap.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 5c916fb2f..57f127efd 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -2006,9 +2006,10 @@ void QDeclarativeGeoMap::removeMapItem(QDeclarativeGeoMapItemBase *ptr)
 */
 void QDeclarativeGeoMap::clearMapItems()
 {
-    m_map->clearMapItems();
     if (m_mapItems.isEmpty())
         return;
+    if (m_map)
+        m_map->clearMapItems();
     for (auto i : qAsConst(m_mapItems)) {
         if (i) {
             i->setMap(0, 0);
-- 
GitLab