summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-13 08:57:46 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-13 21:41:41 -0400
commit954820aa81cb52cfe4442f2c6e81117827e32ccc (patch)
tree5392d9b44ed57542fb60be46a384bf783ed43c59 /desktop-widgets/tab-widgets
parentf0e349cdd68c259f07fd5867d8360cd8d65d50ef (diff)
downloadsubsurface-954820aa81cb52cfe4442f2c6e81117827e32ccc.tar.gz
Dive site: explicitly init displayed_dive_site on show widget
The global object "displayed_dive_site" is used to store the old dive site data for the edit-dive-site widget. The fields of the widget were initialized from this object in the show event. Therefore the object was updated in numerous parts of the code to make sure that it was up-to-date. Instead, move the initialization of the object to the function that also initiatlizes the fields. Call this function explicitly before showing the widget. This makes the data-fow distinctly easier to understand. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp9
1 files changed, 1 insertions, 8 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 179228ea0..322ec5943 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -419,11 +419,9 @@ void MainTab::updateDiveInfo(bool clear)
if (ds) {
ui.location->setCurrentDiveSiteUuid(ds->uuid);
ui.locationTags->setText(constructLocationTags(ds, true));
- copy_dive_site(ds, &displayed_dive_site);
} else {
ui.location->clear();
ui.locationTags->clear();
- clear_dive_site(&displayed_dive_site);
}
// Subsurface always uses "local time" as in "whatever was the local time at the location"
@@ -657,10 +655,8 @@ MainTab::EditMode MainTab::getEditMode() const
void MainTab::refreshDisplayedDiveSite()
{
struct dive_site *ds = get_dive_site_for_dive(&displayed_dive);
- if (ds) {
- copy_dive_site(ds, &displayed_dive_site);
+ if (ds)
ui.location->setCurrentDiveSiteUuid(ds->uuid);
- }
}
// when this is called we already have updated the current_dive and know that it exists
@@ -906,9 +902,6 @@ void MainTab::acceptChanges()
// so let's make sure here that our data is consistent now that we have handled the
// dive sites
displayed_dive.dive_site_uuid = current_dive->dive_site_uuid;
- struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid);
- if (ds)
- copy_dive_site(ds, &displayed_dive_site);
// each dive that was selected might have had the temperatures in its active divecomputer changed
// so re-populate the temperatures - easiest way to do this is by calling fixup_dive