aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/diveplanner.cpp1
-rw-r--r--desktop-widgets/mainwindow.cpp1
-rw-r--r--profile-widget/profilewidget2.cpp5
-rw-r--r--qt-models/diveplannermodel.cpp5
-rw-r--r--qt-models/diveplannermodel.h2
5 files changed, 8 insertions, 6 deletions
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index 014745909..ab2fa8b75 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -563,7 +563,6 @@ void PlannerWidgets::planDive()
void PlannerWidgets::replanDive()
{
- DivePlannerPointsModel::instance()->clear();
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
MainWindow::instance()->graphics->setPlanState();
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 03f0dc57c..2230b05fc 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -1514,7 +1514,6 @@ void MainWindow::editCurrentDive()
return;
disableShortcuts();
- DivePlannerPointsModel::instance()->clear();
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
graphics->setAddState();
setApplicationState(ApplicationState::EditDive);
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 12be6e4a8..b20e6af51 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -1792,7 +1792,10 @@ void ProfileWidget2::repositionDiveHandlers()
QLineF line(p1, p2);
QPointF pos = line.pointAt(0.5);
gases[i]->setPos(pos);
- gases[i]->setText(get_gas_string(get_cylinder(&displayed_dive, datapoint.cylinderid)->gasmix));
+ if (datapoint.cylinderid >= 0 && datapoint.cylinderid < displayed_dive.cylinders.nr)
+ gases[i]->setText(get_gas_string(get_cylinder(&displayed_dive, datapoint.cylinderid)->gasmix));
+ else
+ gases[i]->setText(QString());
gases[i]->setVisible(datapoint.entered &&
(i == 0 || gases[i]->text() != gases[i-1]->text()));
}
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index bb52a1061..e0c0e2d69 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -106,9 +106,10 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
duration_t lasttime = { 0 };
duration_t lastrecordedtime = {};
duration_t newtime = {};
+
+ clear();
free_dps(&diveplan);
- if (mode != PLAN)
- clear();
+
diveplan.when = d->when;
// is this a "new" dive where we marked manually entered samples?
// if yes then the first sample should be marked
diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h
index 52c01dd36..8cc12c5c8 100644
--- a/qt-models/diveplannermodel.h
+++ b/qt-models/diveplannermodel.h
@@ -40,7 +40,6 @@ public:
void setPlanMode(Mode mode);
bool isPlanner() const;
void createSimpleDive();
- void clear();
Mode currentMode() const;
bool setRecalc(bool recalc);
bool recalcQ() const;
@@ -119,6 +118,7 @@ signals:
private:
explicit DivePlannerPointsModel(QObject *parent = 0);
+ void clear();
void setupStartTime();
void setupCylinders();
int lastEnteredPoint() const;