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 <sfuchs@gmx.de>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-10-28 13:56:09 +03:00 committed by Jan Mulder
parent 6d81e19eae
commit 9367610220

View file

@ -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