mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: better handling of NULL dive in setCurrentDiveSite
We test for d being NULL so that's clearly an option we worried about, yet we already called get_dive_site_for_dive(d) which dereferences d. Found by Coverity. Fixes CID 350118 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1951371bbb
commit
130534aedf
1 changed files with 9 additions and 5 deletions
|
@ -567,14 +567,18 @@ void DiveLocationLineEdit::fixPopupPosition()
|
||||||
|
|
||||||
void DiveLocationLineEdit::setCurrentDiveSite(struct dive *d)
|
void DiveLocationLineEdit::setCurrentDiveSite(struct dive *d)
|
||||||
{
|
{
|
||||||
struct dive_site *ds = get_dive_site_for_dive(d);
|
location_t currentLocation;
|
||||||
currDs = ds;
|
if (d) {
|
||||||
|
currDs = get_dive_site_for_dive(d);
|
||||||
|
currentLocation = dive_get_gps_location(d);
|
||||||
|
} else {
|
||||||
|
currDs = nullptr;
|
||||||
|
currentLocation = location_t{0, 0};
|
||||||
|
}
|
||||||
if (!currDs)
|
if (!currDs)
|
||||||
clear();
|
clear();
|
||||||
else
|
else
|
||||||
setText(ds->name);
|
setText(currDs->name);
|
||||||
|
|
||||||
location_t currentLocation = d ? dive_get_gps_location(d) : location_t{0, 0};
|
|
||||||
proxy->setCurrentLocation(currentLocation);
|
proxy->setCurrentLocation(currentLocation);
|
||||||
delegate.setCurrentLocation(currentLocation);
|
delegate.setCurrentLocation(currentLocation);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue