diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-25 21:45:29 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-04-02 13:53:23 -0700 |
commit | e419ebf55a28d2483951e52ca274aedd96f11789 (patch) | |
tree | 32d5168bdaa00cde2216842f62c005fa21779db5 /profile-widget | |
parent | 02ef58a48bfa9042e034e83cb128ae6b7f83628e (diff) | |
download | subsurface-e419ebf55a28d2483951e52ca274aedd96f11789.tar.gz |
planner: move clearing of model into loadFromDive() function
Both loadFromDive() callers were clearing the model before
calling loadFromDive(). Move the clearing into that function
since it makes no sense to load into a non-cleared model.
Apparently this changes the way that no-cylinder dives are
treated and the code in ProfileWidget2::repositionDiveHandlers()
must now explicitly check for that condition.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/profilewidget2.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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())); } |