Do not create a new dive site when curr is invalid

We will however create a new dive site when the user clicks on the add
button - creating it here would led to strange behavior.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-05-26 17:02:50 -03:00 committed by Dirk Hohndel
parent 562ee7410c
commit 609688b489

View file

@ -83,15 +83,9 @@ void LocationInformationWidget::setCurrentDiveSite(int dive_nr)
void LocationInformationWidget::setLocationId(uint32_t uuid)
{
currentDs = get_dive_site_by_uuid(uuid);
if(!currentDs)
return;
if (!currentDs) {
currentDs = get_dive_site_by_uuid(create_dive_site(""));
displayed_dive.dive_site_uuid = currentDs->uuid;
ui.diveSiteName->clear();
ui.diveSiteDescription->clear();
ui.diveSiteNotes->clear();
ui.diveSiteCoordinates->clear();
}
displayed_dive_site = *currentDs;
if (displayed_dive_site.name)
ui.diveSiteName->setText(displayed_dive_site.name);