From b39f2406c6a520f0b3743324744f3c55914adc52 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 30 Aug 2019 16:51:59 +0200 Subject: Map: don't fully reset model on selection change When changing the selection the MapLocationModel was reset. This lead to crashes on Qt-5.9 which are due to QML accessing data that was freed during model reset. This putative Qt bug doesn't happen on newer Qt versions. At least Qt-5.12 is known to work. Instead of fighting the bug, let's simply not reset the model but send a dataChanged() for every element of the MapLocationModel. Signed-off-by: Berthold Stoeger --- map-widget/qmlmapwidgethelper.cpp | 5 +++++ map-widget/qmlmapwidgethelper.h | 1 + 2 files changed, 6 insertions(+) (limited to 'map-widget') diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index feaccdbef..02bfa78a2 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -113,6 +113,11 @@ void MapWidgetHelper::reloadMapLocations() m_mapLocationModel->reload(m_map); } +void MapWidgetHelper::selectionChanged() +{ + m_mapLocationModel->selectionChanged(); +} + void MapWidgetHelper::selectedLocationChanged(struct dive_site *ds_in) { int idx; diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h index af469193e..046cb4ce1 100644 --- a/map-widget/qmlmapwidgethelper.h +++ b/map-widget/qmlmapwidgethelper.h @@ -36,6 +36,7 @@ public: Q_INVOKABLE void updateCurrentDiveSiteCoordinatesFromMap(struct dive_site *ds, QGeoCoordinate coord); Q_INVOKABLE void selectVisibleLocations(); Q_INVOKABLE void selectedLocationChanged(struct dive_site *ds); + void selectionChanged(); QString pluginObject(); bool editMode() const; -- cgit v1.2.3-70-g09d2