From 37ae5a7d83bac4a002597bfc3df977b61d50d5ce Mon Sep 17 00:00:00 2001 From: Michael Werle Date: Wed, 2 Sep 2020 16:01:34 +0900 Subject: [Bug #2930] Fix crash bug in LocationInformationWidget If a user exits the LocationInformationWidget (Edit Dive Site) while a reverseGeocode lookup is in progress, the object's diveSite variable is set to null. When the reverseGeocode lookup completes, this variable is dereferenced causing an application crash. Signed-off-by: Michael Werle --- desktop-widgets/locationinformation.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp index b8a642557..01a1a4390 100644 --- a/desktop-widgets/locationinformation.cpp +++ b/desktop-widgets/locationinformation.cpp @@ -313,12 +313,15 @@ void LocationInformationWidget::on_diveSiteDistance_textChanged(const QString &s void LocationInformationWidget::reverseGeocode() { + dive_site *ds = diveSite; /* Save local copy; possibility of user closing the widget while reverseGeoLookup is running (see #2930) */ location_t location = parseGpsText(ui.diveSiteCoordinates->text()); - if (!diveSite || !has_location(&location)) + if (!ds || !has_location(&location)) return; taxonomy_data taxonomy = { 0, 0 }; reverseGeoLookup(location.lat, location.lon, &taxonomy); - Command::editDiveSiteTaxonomy(diveSite, taxonomy); + if (ds != diveSite) + return; + Command::editDiveSiteTaxonomy(ds, taxonomy); } DiveLocationFilterProxyModel::DiveLocationFilterProxyModel(QObject *) : currentLocation(zero_location) -- cgit v1.2.3-70-g09d2