From 4d0a200cfd20d97f668250e46d5af745d53f6a41 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 13 Apr 2020 18:30:03 +0200 Subject: [PATCH] planner: on printing, restore textual plan using a saved string When printing, the dive plan was prepended with a logo, a disclaimer and the profile. Then it was restored by setting the plan of displayed_dive. Instead, simply save the original plan in a QString and restore that. This removes a further dependency on displayed_dive, which I'd like to make local to the planner. Signed-off-by: Berthold Stoeger --- desktop-widgets/mainwindow.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 116e19c95..8a8981a46 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -808,8 +808,11 @@ void MainWindow::printPlan() { #ifndef NO_PRINTING char *disclaimer = get_planner_disclaimer_formatted(); + // Prepend a logo and a disclaimer to the plan. + // Save the old plan so that it can be restored at the end of the function. + QString origPlan = plannerDetails->divePlanOutput()->toHtml(); QString diveplan = QStringLiteral(" ") + - QString(disclaimer) + plannerDetails->divePlanOutput()->toHtml(); + QString(disclaimer) + origPlan; free(disclaimer); QPrinter printer; @@ -848,7 +851,7 @@ void MainWindow::printPlan() plannerDetails->divePlanOutput()->setHtml(diveplan); plannerDetails->divePlanOutput()->print(&printer); - plannerDetails->divePlanOutput()->setHtml(displayed_dive.notes); + plannerDetails->divePlanOutput()->setHtml(origPlan); // restore original plan #endif }