diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-06-22 16:55:27 -0700 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-06-23 11:29:52 +0200 |
commit | 4b0f90ced33569d50913eb9826a8d96fbc4d9f3a (patch) | |
tree | b8a7d33ef8653a1e63d34813462f47f8c6e46824 | |
parent | 6619bd972c4821b5f2eec7cc2f0290aab8811819 (diff) | |
download | subsurface-4b0f90ced33569d50913eb9826a8d96fbc4d9f3a.tar.gz |
Desktop: use local variable instead of displayed_dive
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 7cf8afc5e..36cabb8cb 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -965,18 +965,17 @@ void MainWindow::on_actionAddDive_triggered() // create a dive an hour from now with a default depth (15m/45ft) and duration (40 minutes) // as a starting point for the user to edit - clear_dive(&displayed_dive); - displayed_dive.id = dive_getUniqID(); - displayed_dive.when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600; - displayed_dive.dc.duration.seconds = 40 * 60; - displayed_dive.dc.maxdepth.mm = M_OR_FT(15, 45); - displayed_dive.dc.meandepth.mm = M_OR_FT(13, 39); // this creates a resonable looking safety stop - displayed_dive.dc.model = strdup("manually added dive"); // don't translate! this is stored in the XML file - displayed_dive.duration = displayed_dive.dc.duration; - fake_dc(&displayed_dive.dc); - fixup_dive(&displayed_dive); - - Command::addDive(&displayed_dive, autogroup, true); + struct dive d = { 0 }; + d.id = dive_getUniqID(); + d.when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600; + d.dc.duration.seconds = 40 * 60; + d.dc.maxdepth.mm = M_OR_FT(15, 45); + d.dc.meandepth.mm = M_OR_FT(13, 39); // this creates a resonable looking safety stop + d.dc.model = strdup("manually added dive"); // don't translate! this is stored in the XML file + fake_dc(&d.dc); + fixup_dive(&d); + + Command::addDive(&d, autogroup, true); // Plot dive actually copies current_dive to displayed_dive and therefore ensures that the // correct data are displayed! |