diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-10-28 13:56:09 +0300 |
---|---|---|
committer | Jan Mulder <jlmulder@xs4all.nl> | 2017-10-29 08:26:11 +0100 |
commit | 9367610220b6bae1db2cfbd24f50774de537fe8b (patch) | |
tree | 5566f7763608bb8df11147b0f86972bd5b9e00ae | |
parent | 6d81e19eae1ecd0fee7dae7a220b8d908df41839 (diff) | |
download | subsurface-9367610220b6bae1db2cfbd24f50774de537fe8b.tar.gz |
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>
-rw-r--r-- | mobile-widgets/qml/MapWidget.qml | 7 |
1 files changed, 6 insertions, 1 deletions
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 |