From a04d9211c1f8d65e5b99d1351f31398965cc0ea2 Mon Sep 17 00:00:00 2001 From: Andrei Popa Date: Thu, 21 Nov 2024 15:13:59 +0200 Subject: [PATCH] general: fix crash on exit at license menu Signed-off-by: Andrei Popa --- core/src/licenseoverlay.cpp | 6 +++++- gui/src/widgets/popupwidget.cpp | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/src/licenseoverlay.cpp b/core/src/licenseoverlay.cpp index 9e2d86a0d7..9edbadfe39 100644 --- a/core/src/licenseoverlay.cpp +++ b/core/src/licenseoverlay.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -40,12 +41,15 @@ LicenseOverlay::LicenseOverlay(QWidget *parent) connect(m_popupWidget->getContinueBtn(), &QAbstractButton::clicked, [&]() { Preferences::GetInstance()->set("general_first_run", false); deleteLater(); + m_popupWidget->deleteLater(); }); Preferences::connect(m_popupWidget->getExitBtn(), &QAbstractButton::clicked, [&]() { QCoreApplication::quit(); }); + + Style::setBackgroundColor(m_popupWidget, json::theme::background_primary); } -LicenseOverlay::~LicenseOverlay() { delete m_popupWidget; } +LicenseOverlay::~LicenseOverlay() {} void LicenseOverlay::showOverlay() { diff --git a/gui/src/widgets/popupwidget.cpp b/gui/src/widgets/popupwidget.cpp index 95b35d44c6..defc0b834e 100644 --- a/gui/src/widgets/popupwidget.cpp +++ b/gui/src/widgets/popupwidget.cpp @@ -36,7 +36,12 @@ PopupWidget::PopupWidget(QWidget *parent) m_continueButton->setFocus(); } -PopupWidget::~PopupWidget() { delete m_tintedOverlay; } +PopupWidget::~PopupWidget() +{ + if(m_tintedOverlay != nullptr) { + m_tintedOverlay->deleteLater(); + } +} void PopupWidget::initUI() { @@ -122,7 +127,7 @@ void PopupWidget::enableTintedOverlay(bool enable) m_tintedOverlay->show(); raise(); show(); - } else { + } else if(m_tintedOverlay != nullptr) { delete m_tintedOverlay; m_tintedOverlay = nullptr; }