diff --git a/src/widgets/basewidget.cpp b/src/widgets/basewidget.cpp index 0d01964b3..4f1cedef8 100644 --- a/src/widgets/basewidget.cpp +++ b/src/widgets/basewidget.cpp @@ -26,6 +26,11 @@ BaseWidget::BaseWidget(BaseWidget *parent, Qt::WindowFlags f) this->init(); } +BaseWidget::~BaseWidget() +{ + this->themeConnection.disconnect(); +} + float BaseWidget::getScale() const { // return 1.f; @@ -82,15 +87,11 @@ void BaseWidget::setScaleIndependantHeight(int value) void BaseWidget::init() { - pajlada::Signals::Connection connection = this->themeManager.updated.connect([this]() { + this->themeConnection = this->themeManager.updated.connect([this]() { this->themeRefreshEvent(); this->update(); }); - - QObject::connect(this, &QObject::destroyed, [connection]() mutable { - connection.disconnect(); // - }); } void BaseWidget::childEvent(QChildEvent *event) diff --git a/src/widgets/basewidget.hpp b/src/widgets/basewidget.hpp index 2e2a9c0bb..32dafa1bb 100644 --- a/src/widgets/basewidget.hpp +++ b/src/widgets/basewidget.hpp @@ -20,6 +20,7 @@ public: explicit BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags()); explicit BaseWidget(BaseWidget *parent, Qt::WindowFlags f = Qt::WindowFlags()); + virtual ~BaseWidget(); singletons::ThemeManager &themeManager; @@ -49,6 +50,8 @@ private: std::vector widgets; + pajlada::Signals::Connection themeConnection; + static void setScaleRecursive(float scale, QObject *object); friend class BaseWindow; diff --git a/src/widgets/helper/signallabel.hpp b/src/widgets/helper/signallabel.hpp index 658e3ccf2..9e89257b8 100644 --- a/src/widgets/helper/signallabel.hpp +++ b/src/widgets/helper/signallabel.hpp @@ -11,7 +11,7 @@ class SignalLabel : public QLabel public: explicit SignalLabel(QWidget *parent = nullptr, Qt::WindowFlags f = 0); - ~SignalLabel() override = default; + virtual ~SignalLabel() override = default; signals: void mouseDoubleClick(QMouseEvent *ev); diff --git a/src/widgets/helper/splitheader.hpp b/src/widgets/helper/splitheader.hpp index e4095eae4..3bfa55415 100644 --- a/src/widgets/helper/splitheader.hpp +++ b/src/widgets/helper/splitheader.hpp @@ -29,7 +29,7 @@ class SplitHeader : public BaseWidget public: explicit SplitHeader(Split *_chatWidget); - ~SplitHeader(); + virtual ~SplitHeader(); // Update channel text from chat widget void updateChannelText();