From 161ecc3c04461435303878d79a5ba766f14b4c40 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Fri, 16 Oct 2020 10:17:29 +0300 Subject: [PATCH] Fix - HistoryWidget is not deleted in Controller --- src/core/controller.cpp | 15 ++++++++++++--- src/core/controller.h | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/core/controller.cpp b/src/core/controller.cpp index fe0c713b..2666d1e8 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -44,6 +44,8 @@ Controller::Controller() : m_captureWindow(nullptr) { + m_history = nullptr; + qApp->setQuitOnLastWindowClosed(false); // set default shortcusts if not set yet @@ -68,6 +70,11 @@ Controller::Controller() qApp->setStyleSheet(StyleSheet); } +Controller::~Controller() +{ + delete m_history; +} + Controller* Controller::getInstance() { static Controller c; @@ -297,9 +304,11 @@ void Controller::updateConfigComponents() void Controller::showRecentScreenshots() { - HistoryWidget* pHistory = new HistoryWidget(); - pHistory->loadHistory(); - pHistory->exec(); + if (nullptr == m_history) { + m_history = new HistoryWidget(); + } + m_history->loadHistory(); + m_history->show(); } void Controller::startFullscreenCapture(const uint id) diff --git a/src/core/controller.h b/src/core/controller.h index 2308abcc..0cb9ee24 100644 --- a/src/core/controller.h +++ b/src/core/controller.h @@ -30,6 +30,7 @@ class ConfigWindow; class InfoWindow; class QSystemTrayIcon; class CaptureLauncher; +class HistoryWidget; using lambda = std::function; class Controller : public QObject @@ -40,6 +41,7 @@ public: static Controller* getInstance(); Controller(const Controller&) = delete; + ~Controller(); void operator=(const Controller&) = delete; void enableExports(); @@ -87,4 +89,6 @@ private: QPointer m_launcherWindow; QPointer m_configWindow; QPointer m_trayIcon; + + HistoryWidget* m_history; };