From 334017be56d91bc6535bde8fe68b2bdb055ab950 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 15 Apr 2016 11:40:15 +0200 Subject: [PATCH] Debugger: Properly clean up dock widgets We call setParent(0) on the dock widgets, not on the actual operation widgets. In order to find out which ones we need to delete we need to check both the operations and the dock widgets. Change-Id: Ia6fde9bc1737aab6b6ad5497b27e805bcd67d0ab Task-number: QTCREATORBUG-16074 Reviewed-by: hjk --- src/plugins/debugger/debuggermainwindow.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 6441fd01761..0b523eb40fa 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -81,12 +81,16 @@ DebuggerMainWindow::~DebuggerMainWindow() { // As we have to setParent(0) on dock widget that are not selected, // we keep track of all and make sure we don't leak any + foreach (QDockWidget *dock, m_dockForDockId) { + if (dock && !dock->parentWidget()) + delete dock; + } + foreach (const Perspective &perspective, m_perspectiveForPerspectiveId) { foreach (const Perspective::Operation &operation, perspective.operations()) { if (operation.widget && !operation.widget->parentWidget()) { - // These are from inactive perspectives. We call setParent(0) when deactivating - // a perspective so that the widgets can't be accidentally enabled in the wrong - // perspectives. That's why we have to delete them manually here. + // These are from perspectives that never got enabled. We've taken ownership for + // those, so we need to delete them. delete operation.widget; } }