From 1ee96f4ad655369114648d0e3ba13444ba38e7b9 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 3 Jun 2015 22:32:13 -0300 Subject: Don't rely on current_dive to get the dive site id Since we are modifying the dive site inside of the dive, we can't ask the dive for the new one, and we also can't use the name of the dive site, as there's the possibility that two or more could have the same name, so rely only on the index of it to get the uuid. The index is variable since we will sort the dive_site_table alphabetically, but this doesn't matter since we are using it only temporarely to get the uuid, and this one never changes. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'qt-ui/maintab.cpp') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index f4c0d3af3..e5204a285 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -1275,20 +1275,29 @@ void MainTab::on_tagWidget_textChanged() * mostly the same ). Check the currentTrip there to see if it`s being * correctly triggered. */ -void MainTab::on_location_currentTextChanged(const QString &text) + + +void MainTab::on_location_currentIndexChanged(int idx) { if (editMode == IGNORE || acceptingEdit == true) return; + if (currentTrip) { free(displayedTrip.location); displayedTrip.location = strdup(qPrintable(ui.location->currentText())); } - if (current_dive && text == QString(get_dive_site_by_uuid(displayed_dive.dive_site_uuid)->name)) + + if (!get_dive_site(idx)) return; - uint32_t uuid = ui.location->currentData(LocationInformationModel::DIVE_SITE_UUID).toInt(); - displayed_dive.dive_site_uuid = uuid; - markChangedWidget(ui.location); + if (current_dive) { + struct dive_site *ds_from_dive = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); + if(ds_from_dive && ui.location->currentText() == ds_from_dive->name) + return; + displayed_dive.dive_site_uuid = get_dive_site(idx)->uuid; + markChangedWidget(ui.location); + emit diveSiteChanged(); + } } /* TODO: -- cgit v1.2.3-70-g09d2