fixed crash when changing theme after closing tab

This commit is contained in:
fourtf 2018-04-13 23:17:10 +02:00
parent 2c5d05dfa1
commit 1654130dbc
4 changed files with 11 additions and 7 deletions

View file

@ -26,6 +26,11 @@ BaseWidget::BaseWidget(BaseWidget *parent, Qt::WindowFlags f)
this->init(); this->init();
} }
BaseWidget::~BaseWidget()
{
this->themeConnection.disconnect();
}
float BaseWidget::getScale() const float BaseWidget::getScale() const
{ {
// return 1.f; // return 1.f;
@ -82,15 +87,11 @@ void BaseWidget::setScaleIndependantHeight(int value)
void BaseWidget::init() void BaseWidget::init()
{ {
pajlada::Signals::Connection connection = this->themeManager.updated.connect([this]() { this->themeConnection = this->themeManager.updated.connect([this]() {
this->themeRefreshEvent(); this->themeRefreshEvent();
this->update(); this->update();
}); });
QObject::connect(this, &QObject::destroyed, [connection]() mutable {
connection.disconnect(); //
});
} }
void BaseWidget::childEvent(QChildEvent *event) void BaseWidget::childEvent(QChildEvent *event)

View file

@ -20,6 +20,7 @@ public:
explicit BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent, explicit BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent,
Qt::WindowFlags f = Qt::WindowFlags()); Qt::WindowFlags f = Qt::WindowFlags());
explicit BaseWidget(BaseWidget *parent, Qt::WindowFlags f = Qt::WindowFlags()); explicit BaseWidget(BaseWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
virtual ~BaseWidget();
singletons::ThemeManager &themeManager; singletons::ThemeManager &themeManager;
@ -49,6 +50,8 @@ private:
std::vector<BaseWidget *> widgets; std::vector<BaseWidget *> widgets;
pajlada::Signals::Connection themeConnection;
static void setScaleRecursive(float scale, QObject *object); static void setScaleRecursive(float scale, QObject *object);
friend class BaseWindow; friend class BaseWindow;

View file

@ -11,7 +11,7 @@ class SignalLabel : public QLabel
public: public:
explicit SignalLabel(QWidget *parent = nullptr, Qt::WindowFlags f = 0); explicit SignalLabel(QWidget *parent = nullptr, Qt::WindowFlags f = 0);
~SignalLabel() override = default; virtual ~SignalLabel() override = default;
signals: signals:
void mouseDoubleClick(QMouseEvent *ev); void mouseDoubleClick(QMouseEvent *ev);

View file

@ -29,7 +29,7 @@ class SplitHeader : public BaseWidget
public: public:
explicit SplitHeader(Split *_chatWidget); explicit SplitHeader(Split *_chatWidget);
~SplitHeader(); virtual ~SplitHeader();
// Update channel text from chat widget // Update channel text from chat widget
void updateChannelText(); void updateChannelText();