From 94e51803301d8dfb68e2aaf2b2bc04f10d5c2b09 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 7 Oct 2020 23:09:25 +0000 Subject: [PATCH] Fix memory leak of PanelViews on shutdown The current code is broken as the course of events is: - we delete the containment - an existing connect to containment deleted goes to panelContainmentDestroyed - this updates m_panelViews and calls deleteLater - this deleteLater isn't run before other exit handlers (cherry picked from commit d58036769248775911cc8cafaae77a577c2a35a9) --- shell/shellcorona.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp index e1980fefb..0d3c2475e 100644 --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -252,11 +252,10 @@ ShellCorona::ShellCorona(QObject *parent) ShellCorona::~ShellCorona() { while (!containments().isEmpty()) { - //deleting a containment will remove it from the list due to QObject::destroyed connect in Corona + // Deleting a containment will remove it from the list due to QObject::destroyed connect in Corona + // Deleting a containment in turn also kills any panel views delete containments().first(); } - qDeleteAll(m_panelViews); - m_panelViews.clear(); } KPackage::Package ShellCorona::lookAndFeelPackage() @@ -1381,7 +1380,7 @@ void ShellCorona::createWaitingPanels() void ShellCorona::panelContainmentDestroyed(QObject *cont) { auto view = m_panelViews.take(static_cast(cont)); - view->deleteLater(); + delete view; //don't make things relayout when the application is quitting //NOTE: qApp->closingDown() is still false here if (!m_closingDown) {