summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2017-10-19 15:29:59 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-10-19 14:57:02 -0400
commita422957cd6525b9753cafacfafdf1f3eef66870d (patch)
treef29ace3e6f2681c71901d061aab6035b8505629f /desktop-widgets/mainwindow.cpp
parenta9b692f0c30fecf950c52099d7c0f336f88c901f (diff)
downloadsubsurface-a422957cd6525b9753cafacfafdf1f3eef66870d.tar.gz
Use displayed_dc instead of current_dc
current_dc is a macro that determines the dive computer based on the current dive number. When the planner is started from an emtpy dive list, the dive number ends up being -1 and that doesn't produce a valid dive computer. Use the divecomputer of the displayed_dive instead. This is done via a macro that can also be used in two other places. Without this patch, the planner crashed when called on an empty dive list. Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r--desktop-widgets/mainwindow.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 44384bfb7..1445ea93b 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -909,6 +909,7 @@ void MainWindow::setupForAddAndPlan(const char *model)
displayed_dive.id = dive_getUniqID(&displayed_dive);
displayed_dive.when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600;
displayed_dive.dc.model = strdup(model); // don't translate! this is stored in the XML file
+ dc_number = 1;
// setup the dive cylinders
DivePlannerPointsModel::instance()->clear();
DivePlannerPointsModel::instance()->setupCylinders();