From 72a5acc335d0fd3f8f4575175636ab3f38244f6c Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Thu, 30 Jan 2020 07:59:33 -0500 Subject: [PATCH] Revert "Use RAII to manage QApplication memory" This breaks the logic for the KDBusService crash fix. If this (using unique_ptr) needs to be done it needs to carefully release() and reset() at every step, and then it's just easier to manually delete it where appropriate IMHO. This reverts commit d5d8496cd285cf988884e99d29d76367cfcd742f. Differential Revision: https://phabricator.kde.org/D26764 --- src/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1b3ce41b..5ab7e2a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,7 +32,6 @@ #include #include #include -#include // KDE #include @@ -108,8 +107,7 @@ extern "C" int Q_DECL_EXPORT kdemain(int argc, char *argv[]) qputenv("QT_NO_GLIB", "1"); #endif - // Allocate QApplication on the heap for the KDBusService workaround - auto app = std::unique_ptr(new QApplication(argc, argv)); + auto app = new QApplication(argc, argv); app->setStyle(new MenuStyle()); #if defined(Q_OS_LINUX) && (QT_VERSION < QT_VERSION_CHECK(5, 11, 2)) @@ -221,11 +219,15 @@ extern "C" int Q_DECL_EXPORT kdemain(int argc, char *argv[]) // 2. An invalid situation occurred const bool continueStarting = (konsoleApp.newInstance() != 0); if (!continueStarting) { + delete app; return 0; } } + // Since we've allocated the QApplication on the heap for the KDBusService workaround, + // we need to delete it manually before returning from main(). int ret = app->exec(); + delete app; return ret; }