From 1ff1bf3292e9d1d0cdf23ba0ae1a14a3afb20cc9 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 10 Nov 2020 19:06:26 +0100 Subject: [PATCH] Only call deleteLater when proxystyle is set --- src/widgets/fancytabwidget.cpp | 6 ++++-- src/widgets/fancytabwidget.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/widgets/fancytabwidget.cpp b/src/widgets/fancytabwidget.cpp index d26994875..b98f1976a 100644 --- a/src/widgets/fancytabwidget.cpp +++ b/src/widgets/fancytabwidget.cpp @@ -438,6 +438,7 @@ class FancyTabWidgetProxyStyle : public QProxyStyle { }; FancyTabWidget::FancyTabWidget(QWidget *parent) : QTabWidget(parent), + style_(nullptr), menu_(nullptr), mode_(Mode_None), bottom_widget_(nullptr), @@ -454,7 +455,8 @@ FancyTabWidget::FancyTabWidget(QWidget *parent) : QTabWidget(parent), setElideMode(Qt::ElideNone); setUsesScrollButtons(true); if (QApplication::style() && QApplication::style()->objectName().toLower().contains(QRegularExpression("^adwaita.*$"))) { - setStyle(new FancyTabWidgetProxyStyle(style())); + style_ = new FancyTabWidgetProxyStyle(style()); + setStyle(style_); } connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int))); @@ -462,7 +464,7 @@ FancyTabWidget::FancyTabWidget(QWidget *parent) : QTabWidget(parent), } FancyTabWidget::~FancyTabWidget() { - style()->deleteLater(); + if (style_) style_->deleteLater(); } void FancyTabWidget::Load(const QString &kSettingsGroup) { diff --git a/src/widgets/fancytabwidget.h b/src/widgets/fancytabwidget.h index 27ddd170f..e6c7eacb4 100644 --- a/src/widgets/fancytabwidget.h +++ b/src/widgets/fancytabwidget.h @@ -37,6 +37,7 @@ class QMenu; class QActionGroup; class QContextMenuEvent; class QPaintEvent; +class QProxyStyle; class TabData; namespace Core { @@ -102,6 +103,7 @@ class FancyTabWidget : public QTabWidget { private: void addMenuItem(QActionGroup* group, const QString& text, Mode mode); + QProxyStyle *style_; QPixmap background_pixmap_; QMenu *menu_; Mode mode_;