From a0433d089aa96ff60b625be10082e914c19b58d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 3 Nov 2016 10:55:48 +0100 Subject: [PATCH] [kstyle] Implement application unpolish to delete ShadowHelper Summary: Another change mostly for KWin (Wayland compositor). KWin destroys it's internal Wayland connection prior to the QStyle getting destroyed. As the ShadowHelper initialized Wayland objects those would be destroyed after the connection is destroyed. With latest Wayland library this would cause a crash. Thus unpolish is implemented in the style and deletes the ShadowHelper. KWin can on tear down invoke the unpolish and thus make sure it doesn't crash. CCBUG: 372001 Reviewers: #plasma, broulik, hpereiradacosta Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D3240 --- kstyle/breezestyle.cpp | 15 +++++++++++++++ kstyle/breezestyle.h | 7 ++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp index d3f6d46b..ab814ddc 100644 --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -197,9 +197,24 @@ namespace Breeze //______________________________________________________________ Style::~Style( void ) + { + cleanup(); + } + + //______________________________________________________________ + void Style::unpolish( QApplication* ) + { + // NOTE: unpolish is not called in general on tear-down of Application + // only when a new QStyle is loaded by the QApplication unpolish is invoked + cleanup(); + } + + void Style::cleanup( void ) { delete _shadowHelper; + _shadowHelper = nullptr; delete _helper; + _helper = nullptr; } //______________________________________________________________ diff --git a/kstyle/breezestyle.h b/kstyle/breezestyle.h index a627252a..aa2478b6 100644 --- a/kstyle/breezestyle.h +++ b/kstyle/breezestyle.h @@ -92,7 +92,6 @@ namespace Breeze //* needed to avoid warnings at compilation time using ParentStyleClass::polish; - using ParentStyleClass::unpolish; //* widget polishing virtual void polish( QWidget* ); @@ -100,6 +99,9 @@ namespace Breeze //* widget unpolishing virtual void unpolish( QWidget* ); + //* application unpolishing + void unpolish( QApplication* ) override; + //* polish scrollarea void polishScrollArea( QAbstractScrollArea* ); @@ -471,6 +473,9 @@ namespace Breeze private: + //* shared cleanup for unpolish and dtor + void cleanup(); + //*@name scrollbar button types (for addLine and subLine ) //@{ ScrollBarButtonType _addLineButtons;