From 921e81fad89a3a196e99f4e676d2cbfb49dae686 Mon Sep 17 00:00:00 2001 From: Michel Dagenais Date: Sat, 13 Mar 2021 15:16:22 -0500 Subject: [PATCH] Insure that Web pages are deleted before the Web Profile to avoir error messages (#3845) When exiting, GC complains that the Web Profile is released before Web pages that refer to it with the message: "Release of profile requested but WebEnginePage still not deleted. Expect troubles !". The Web pages are now released explicitly in the destructor to insure that they are freed earlier than the Profile. Fixes #3844 --- src/Charts/LTMWindow.cpp | 1 + src/Charts/PythonChart.cpp | 4 ++++ src/Charts/PythonChart.h | 1 + src/Charts/RideMapWindow.cpp | 1 + src/Charts/RideSummaryWindow.cpp | 1 + src/Cloud/OAuthDialog.cpp | 6 ++++++ src/Cloud/OAuthDialog.h | 1 + src/Core/GcUpgrade.cpp | 5 +++++ src/Core/GcUpgrade.h | 1 + src/Gui/GcCrashDialog.cpp | 5 +++++ src/Gui/GcCrashDialog.h | 1 + src/Train/LiveMapWebPageWindow.cpp | 1 + src/Train/WebPageWindow.cpp | 1 + 13 files changed, 29 insertions(+) diff --git a/src/Charts/LTMWindow.cpp b/src/Charts/LTMWindow.cpp index f7559d9c2..8eccdf805 100644 --- a/src/Charts/LTMWindow.cpp +++ b/src/Charts/LTMWindow.cpp @@ -356,6 +356,7 @@ LTMWindow::LTMWindow(Context *context) : LTMWindow::~LTMWindow() { delete popup; + if (dataSummary) delete dataSummary->page(); } void diff --git a/src/Charts/PythonChart.cpp b/src/Charts/PythonChart.cpp index b1cb251c8..a8470fbe1 100644 --- a/src/Charts/PythonChart.cpp +++ b/src/Charts/PythonChart.cpp @@ -410,6 +410,10 @@ PythonChart::PythonChart(Context *context, bool ridesummary) : GcChartWindow(con web->setChecked(true); } +PythonChart::~PythonChart() +{ + if (canvas) delete canvas->page(); +} // switch between rendering to a web page and rendering to a chart page void diff --git a/src/Charts/PythonChart.h b/src/Charts/PythonChart.h index 546b8311f..4701b23d9 100644 --- a/src/Charts/PythonChart.h +++ b/src/Charts/PythonChart.h @@ -101,6 +101,7 @@ class PythonChart : public GcChartWindow, public PythonHost { public: PythonChart(Context *context, bool ridesummary); + ~PythonChart(); // reveal bool hasReveal() { return true; } diff --git a/src/Charts/RideMapWindow.cpp b/src/Charts/RideMapWindow.cpp index ff3e2b609..2a70d8ad1 100644 --- a/src/Charts/RideMapWindow.cpp +++ b/src/Charts/RideMapWindow.cpp @@ -173,6 +173,7 @@ RideMapWindow::RideMapWindow(Context *context, int mapType) : GcChartWindow(cont RideMapWindow::~RideMapWindow() { delete webBridge; + if (view) delete view->page(); } void diff --git a/src/Charts/RideSummaryWindow.cpp b/src/Charts/RideSummaryWindow.cpp index b02c51f57..4bd2c1e56 100644 --- a/src/Charts/RideSummaryWindow.cpp +++ b/src/Charts/RideSummaryWindow.cpp @@ -146,6 +146,7 @@ RideSummaryWindow::~RideSummaryWindow() // cancel background thread if needed future.cancel(); future.waitForFinished(); + if (rideSummary) delete rideSummary->page(); } void diff --git a/src/Cloud/OAuthDialog.cpp b/src/Cloud/OAuthDialog.cpp index 2576f0356..8019cfef6 100644 --- a/src/Cloud/OAuthDialog.cpp +++ b/src/Cloud/OAuthDialog.cpp @@ -203,6 +203,12 @@ OAuthDialog::OAuthDialog(Context *context, OAuthSite site, CloudService *service } } +OAuthDialog::~OAuthDialog() +{ + if (view) delete view->page(); + delete view; // view was constructed without a parent to delete it +} + // just ignore SSL handshake errors at all times void OAuthDialog::onSslErrors(QNetworkReply *reply, const QList&) diff --git a/src/Cloud/OAuthDialog.h b/src/Cloud/OAuthDialog.h index 381590714..5d2b4f8c9 100644 --- a/src/Cloud/OAuthDialog.h +++ b/src/Cloud/OAuthDialog.h @@ -62,6 +62,7 @@ public: // will work with old config via site and new via cloudservice (which is null for calendar and withings for now) OAuthDialog(Context *context, OAuthSite site, CloudService *service, QString baseURL="", QString clientsecret=""); + ~OAuthDialog(); bool sslLibMissing() { return noSSLlib; } diff --git a/src/Core/GcUpgrade.cpp b/src/Core/GcUpgrade.cpp index 2b3b92770..5ebabb61b 100644 --- a/src/Core/GcUpgrade.cpp +++ b/src/Core/GcUpgrade.cpp @@ -981,6 +981,11 @@ GcUpgradeLogDialog::GcUpgradeLogDialog(QDir homeDir) : QDialog(NULL, Qt::Dialog) report->page()->setHtml(reportText); } +GcUpgradeLogDialog::~GcUpgradeLogDialog() +{ + if (report) delete report->page(); +} + void GcUpgradeLogDialog::saveAs() { diff --git a/src/Core/GcUpgrade.h b/src/Core/GcUpgrade.h index 33d6377b8..1b7b69d70 100644 --- a/src/Core/GcUpgrade.h +++ b/src/Core/GcUpgrade.h @@ -125,6 +125,7 @@ class GcUpgradeLogDialog : public QDialog public: GcUpgradeLogDialog(QDir); + ~GcUpgradeLogDialog(); void enableButtons(); void append(QString, int level=0); diff --git a/src/Gui/GcCrashDialog.cpp b/src/Gui/GcCrashDialog.cpp index 7206e1df3..e8323639b 100644 --- a/src/Gui/GcCrashDialog.cpp +++ b/src/Gui/GcCrashDialog.cpp @@ -154,6 +154,11 @@ GcCrashDialog::GcCrashDialog(QDir homeDir) : QDialog(NULL, Qt::Dialog), home(hom setHTML(); } +GcCrashDialog::~GcCrashDialog() +{ + if (report) delete report->page(); +} + QString GcCrashDialog::versionHTML() { // -- OS ---- diff --git a/src/Gui/GcCrashDialog.h b/src/Gui/GcCrashDialog.h index 916b50d35..544259926 100644 --- a/src/Gui/GcCrashDialog.h +++ b/src/Gui/GcCrashDialog.h @@ -35,6 +35,7 @@ class GcCrashDialog : public QDialog public: GcCrashDialog(QDir); + ~GcCrashDialog(); AthleteDirectoryStructure home; static QString versionHTML(); diff --git a/src/Train/LiveMapWebPageWindow.cpp b/src/Train/LiveMapWebPageWindow.cpp index 4b94248ae..7f19b37e3 100644 --- a/src/Train/LiveMapWebPageWindow.cpp +++ b/src/Train/LiveMapWebPageWindow.cpp @@ -131,6 +131,7 @@ void LiveMapWebPageWindow::userUrl() LiveMapWebPageWindow::~LiveMapWebPageWindow() { + if (view) delete view->page(); } void LiveMapWebPageWindow::ergFileSelected(ErgFile* f) diff --git a/src/Train/WebPageWindow.cpp b/src/Train/WebPageWindow.cpp index c936b7137..b02b44bc0 100644 --- a/src/Train/WebPageWindow.cpp +++ b/src/Train/WebPageWindow.cpp @@ -181,6 +181,7 @@ WebPageWindow::WebPageWindow(Context *context) : GcChartWindow(context), context WebPageWindow::~WebPageWindow() { + if (view) delete view->page(); } void