From b3fd824d189056b845452d57fb967a2b50550921 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 25 Aug 2019 12:21:37 +0200 Subject: [PATCH] Map: catch null divesites in map widget selection code Just to be sure, refuse to add null divesites to the selection. Moreover, refuse to call the setSelected function on a null-divesite. I got an unfriendly Qt-Warning there: "Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated." "This will throw a JavaScript TypeError in future releases of Qt!" Signed-off-by: Berthold Stoeger --- map-widget/qml/MapWidget.qml | 2 +- qt-models/maplocationmodel.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/map-widget/qml/MapWidget.qml b/map-widget/qml/MapWidget.qml index 88e9d95a6..602b7c338 100644 --- a/map-widget/qml/MapWidget.qml +++ b/map-widget/qml/MapWidget.qml @@ -69,7 +69,7 @@ Item { drag.target: (mapHelper.editMode && mapHelper.model.isSelected(model.divesite)) ? mapItem : undefined anchors.fill: parent onClicked: { - if (!mapHelper.editMode) + if (!mapHelper.editMode && model.divesite) mapHelper.model.setSelected(model.divesite, true) } onDoubleClicked: map.doubleClickHandler(mapItem.coordinate) diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp index 1acea421e..da0ec7337 100644 --- a/qt-models/maplocationmodel.cpp +++ b/qt-models/maplocationmodel.cpp @@ -196,6 +196,8 @@ void MapLocationModel::reload(QObject *map) void MapLocationModel::setSelected(struct dive_site *ds, bool fromClick) { m_selectedDs.clear(); + if (!ds) + return; m_selectedDs.append(ds); if (fromClick) emit selectedLocationChanged(getMapLocation(ds));