summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-06-22 12:12:09 -0700
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2019-06-23 11:29:52 +0200
commit6619bd972c4821b5f2eec7cc2f0290aab8811819 (patch)
treebbe53c6f1df07b547219597b8d2ed89f2a544f7a /desktop-widgets/mainwindow.cpp
parent21b275c4fde6a580640d1e56b8a7e013f38c06db (diff)
downloadsubsurface-6619bd972c4821b5f2eec7cc2f0290aab8811819.tar.gz
Desktop: don't use planner to manually add dive
Instead of calling into the planner, simply create the dive computer information right there, using the existing helper function we have to create simple profiles. Fixes #2128 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r--desktop-widgets/mainwindow.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 2f3db5b2c..7cf8afc5e 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -18,6 +18,7 @@
#include <QtConcurrentRun>
#include "core/color.h"
+#include "core/device.h"
#include "core/divecomputer.h"
#include "core/divesitehelpers.h"
#include "core/file.h"
@@ -962,21 +963,18 @@ void MainWindow::on_actionAddDive_triggered()
if (!plannerStateClean())
return;
- // TODO: We (mis)use displayed_dive to construct a default dive using the dive planner.
- // This means that we have to do all this in a setPlanState()/setProfileState() pair,
- // to avoid the profile and planner going out of sync (which in turn can lead to crashes).
- // This should all be simplified. There is no apparent no reason to go via the planner
- // to create a default profile.
+ // 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);
- graphics->setPlanState();
- DivePlannerPointsModel::instance()->setupStartTime();
- DivePlannerPointsModel::instance()->createSimpleDive();
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
- fixup_dc_duration(&displayed_dive.dc);
displayed_dive.duration = displayed_dive.dc.duration;
- graphics->setProfileState();
+ fake_dc(&displayed_dive.dc);
+ fixup_dive(&displayed_dive);
Command::addDive(&displayed_dive, autogroup, true);