From 49ab30ae8b65c3ad443a5824ae5f9554e88c7a39 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 13 Jul 2015 17:11:03 -0300 Subject: Change Location Management to make Linus Happy Do not overwrite a dive site if the name is the same as any other dive site, create a new one and duplicate the information. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 66e42e3c4..2efaa520c 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -841,8 +841,15 @@ void MainTab::updateDisplayedDiveSite() displayed_dive.dive_site_uuid = new_uuid; copy_dive_site(get_dive_site_by_uuid(displayed_dive.dive_site_uuid), &displayed_dive_site); } else if (new_name.count() && orig_name != new_name) { - displayed_dive.dive_site_uuid = find_or_create_dive_site_with_name(qPrintable(new_name)); - copy_dive_site(get_dive_site_by_uuid(displayed_dive.dive_site_uuid), &displayed_dive_site); + // As per linus request.: If I enter the name of a dive site, + // do not select a new one, but "clone" the old one and copy + // the information of it, just changing it's name. + uint32_t new_ds_uuid = create_dive_site(NULL); + struct dive_site *new_ds = get_dive_site_by_uuid(new_ds_uuid); + copy_dive_site(&displayed_dive_site, new_ds); + new_ds->name = copy_string(qPrintable(new_name)); + displayed_dive.dive_site_uuid = new_ds->uuid; + copy_dive_site(new_ds, &displayed_dive_site); } else { qDebug() << "Current divesite is the same as informed"; } -- cgit v1.2.3-70-g09d2