From 9367610220b6bae1db2cfbd24f50774de537fe8b Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Sat, 28 Oct 2017 13:56:09 +0300 Subject: mapwidget: add the 'isReady' flag to the Map component The 'isReady' boolean flag is now set to 'true' only once the Component.onCompleted slot is reached. The flag is then used as a safe-guard in the onZoomLevelChanged slot. Calculate the small circle radius (mapHelper.calculateSmallCircleRadius()) only if 'isReady' is set to true. Prevents a crash if the Map widget is not ready, yet a zoom level is set via the 'zoomLevel' property. The crash happens because mapHelper.calculateSmallCircleRadius() has a callback to the Map component to estimate some points and distances of the small circle. Reported-by: Stefan Fuchs Signed-off-by: Lubomir I. Ivanov --- mobile-widgets/qml/MapWidget.qml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'mobile-widgets/qml') diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml index b1e438ad2..2a3283482 100644 --- a/mobile-widgets/qml/MapWidget.qml +++ b/mobile-widgets/qml/MapWidget.qml @@ -37,8 +37,13 @@ Item { property real newZoom: 1.0 property real newZoomOut: 1.0 property var clickCoord: QtPositioning.coordinate(0, 0) + property bool isReady: false - onZoomLevelChanged: mapHelper.calculateSmallCircleRadius(map.center) + Component.onCompleted: isReady = true + onZoomLevelChanged: { + if (isReady) + mapHelper.calculateSmallCircleRadius(map.center) + } MapItemView { id: mapItemView -- cgit v1.2.3-70-g09d2