diff options
author | Michael Werle <micha@michaelwerle.com> | 2020-09-02 16:01:34 +0900 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2020-09-03 08:59:08 +0200 |
commit | 37ae5a7d83bac4a002597bfc3df977b61d50d5ce (patch) | |
tree | 39bc0f5ef5f503484048fdd791fd97ede73804ab /desktop-widgets/locationinformation.cpp | |
parent | 7e82205e9b7b14e960dc1e83fcf6ef927e746fba (diff) | |
download | subsurface-37ae5a7d83bac4a002597bfc3df977b61d50d5ce.tar.gz |
[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 <micha@michaelwerle.com>
Diffstat (limited to 'desktop-widgets/locationinformation.cpp')
-rw-r--r-- | desktop-widgets/locationinformation.cpp | 7 |
1 files 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) |