From 9b3d268f5f36ce7a635875223469bc4e8e2b3542 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sat, 27 Aug 2016 10:40:38 +0200 Subject: [PATCH] Fix crash on exit Since Qt 5.6.0, Qt5 applications started crashing on exit. All signs point to this delete-on-destroy hack which was added to avoid outliving the plugin lifetime. This method is wrong because the returned style is owned by the caller (QApplication, QProxyStyle, etc) and will cleaned up when those users are destructed. Review: 128760 --- kstyle/breezestyleplugin.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/kstyle/breezestyleplugin.cpp b/kstyle/breezestyleplugin.cpp index 083100e..bcb10de 100644 --- a/kstyle/breezestyleplugin.cpp +++ b/kstyle/breezestyleplugin.cpp @@ -35,15 +35,7 @@ namespace Breeze { if( key.toLower() == QStringLiteral( "breeze" ) ) { - QStyle* style = new Style(); - #if QT_VERSION >= 0x050000 - // Delete style when using ::exit() otherwise it'll outlive the unloaded plugin and we'll get a crash - // (see 2ffe20e1bfe93c921c5372b4d21447b1de308d4b in oxygen repo) - connect(this, &QObject::destroyed, style, [style]() { - delete style; - }); - #endif - return style; + return new Style; } return nullptr; } -- 2.10.2