diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-13 13:45:52 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-03 14:47:49 -0700 |
commit | 17556cc66cedc84aaf6de2bfabcafbcca8bda53c (patch) | |
tree | 1f930db50cd8611d26fd006935f4f9abd1a8e97f /profile-widget | |
parent | c1963fd5ddd82b5ed0133ce6b04be9d525e27d89 (diff) | |
download | subsurface-17556cc66cedc84aaf6de2bfabcafbcca8bda53c.tar.gz |
profile: don't interpret NULL as current_dive in plotDive()
ProfileWidget2::plotDive() had this weird interface, where passing
in NULL as dive would mean "show current_dive". However, most callers
would already pass in current_dive. Therefore, unify and always pass
in current_dive if the caller wants to draw the current dive.
This allows us to interpret NULL as "show empty profile". Thus,
passing in current_dive when there is no current_dive simply shows
an empty profile. This makes the calling code in
MainWindow::selectionChanged() simpler.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/profilewidget2.cpp | 10 | ||||
-rw-r--r-- | profile-widget/profilewidget2.h | 2 |
2 files changed, 4 insertions, 8 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index f0afc0e73..71db3d66f 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -381,8 +381,7 @@ void ProfileWidget2::setupItemOnScene() void ProfileWidget2::replot() { - dataModel->clear(); - plotDive(nullptr, true, false); + plotDive(current_dive, true, false); } void ProfileWidget2::createPPGas(PartialPressureGasItem *item, int verticalColumn, color_index_t color, color_index_t colorAlert, @@ -566,11 +565,8 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict #endif if (currentState != ADD && currentState != PLAN) { if (!d) { - if (!current_dive) { - setEmptyState(); - return; - } - d = current_dive; // display the current dive + setEmptyState(); + return; } // No need to do this again if we are already showing the same dive diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h index 2e530261d..96191a1d6 100644 --- a/profile-widget/profilewidget2.h +++ b/profile-widget/profilewidget2.h @@ -76,7 +76,7 @@ public: ~ProfileWidget2(); void resetZoom(); void scale(qreal sx, qreal sy); - void plotDive(const struct dive *d = 0, bool force = false, bool clearPictures = false, bool instant = false); + void plotDive(const struct dive *d, bool force = false, bool clearPictures = false, bool instant = false); void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *vAxis, int vData, int hData, int zValue); void setPrintMode(bool mode, bool grayscale = false); bool getPrintMode(); |