[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>
This commit is contained in:
Michael Werle 2020-09-02 16:01:34 +09:00 committed by bstoeger
parent 7e82205e9b
commit 37ae5a7d83

View file

@ -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)