From 6b2e56e5131aa707216c4b0da5805199fcc0034d Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Sat, 3 Jul 2021 14:41:55 +0200 Subject: Handle dives with no samples This occurs upon importing dives for example via CSV. Make sure the profile display is cleared when selecting such a dive rather than showing a different dive. Allow editing the profile for such a dive. Signed-off-by: Robert C. Helling --- profile-widget/profilewidget2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index e64f07b22..f0c3f1d0a 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -528,8 +528,10 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool doClearPict } const struct divecomputer *currentdc = get_dive_dc_const(d, dc); - if (!currentdc || !currentdc->samples) + if (!currentdc || !currentdc->samples) { + setEmptyState(); return; + } // special handling when switching from empty state animSpeed = instant || currentState == EMPTY || printMode ? 0 : qPrefDisplay::animation_speed(); @@ -1359,7 +1361,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) changeMode->addAction(gettextFromC::tr(divemode_text_ui[PSCR]), [this, seconds](){ addDivemodeSwitch(seconds, PSCR); }); - if (same_string(get_dive_dc_const(d, dc)->model, "manually added dive")) + if (same_string(get_dive_dc_const(d, dc)->model, "manually added dive") || !get_dive_dc_const(d, dc)->samples) m.addAction(tr("Edit the profile"), this, &ProfileWidget2::editCurrentDive); if (DiveEventItem *item = dynamic_cast(sceneItem)) { -- cgit v1.2.3-70-g09d2