From 17556cc66cedc84aaf6de2bfabcafbcca8bda53c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 13 Apr 2020 13:45:52 +0200 Subject: 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 --- desktop-widgets/mainwindow.cpp | 7 +++---- desktop-widgets/printer.cpp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index a0a0dded0..efe83ad9b 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -453,13 +453,12 @@ void MainWindow::selectionChanged() if (!current_dive) { mainTab->clearTabs(); mainTab->updateDiveInfo(); - graphics->setEmptyState(); } else { - graphics->plotDive(nullptr, false, true); mainTab->updateDiveInfo(); configureToolbar(); enableDisableOtherDCsActions(); } + graphics->plotDive(current_dive, false, true); MapWidget::instance()->selectionChanged(); } @@ -1112,7 +1111,7 @@ void MainWindow::on_actionPreviousDC_triggered() unsigned nrdc = number_of_computers(current_dive); dc_number = (dc_number + nrdc - 1) % nrdc; configureToolbar(); - graphics->plotDive(nullptr, false, true); + graphics->plotDive(current_dive, false, true); mainTab->updateDiveInfo(); } @@ -1121,7 +1120,7 @@ void MainWindow::on_actionNextDC_triggered() unsigned nrdc = number_of_computers(current_dive); dc_number = (dc_number + 1) % nrdc; configureToolbar(); - graphics->plotDive(nullptr, false, true); + graphics->plotDive(current_dive, false, true); mainTab->updateDiveInfo(); } diff --git a/desktop-widgets/printer.cpp b/desktop-widgets/printer.cpp index 9de1e41be..cd7c11345 100644 --- a/desktop-widgets/printer.cpp +++ b/desktop-widgets/printer.cpp @@ -185,7 +185,7 @@ void Printer::render(int Pages = 0) qPrefDisplay::set_animation_speed(animationOriginal); //replot the dive after returning the settings - profile->plotDive(0, true, true); + profile->plotDive(current_dive, true, true); } //value: ranges from 0 : 100 and shows the progress of the templating engine -- cgit v1.2.3-70-g09d2