From 0c2bc9c2daf29da6e6869e98491736e10c46298e Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 31 Jul 2018 12:30:48 +0200 Subject: [PATCH] Debugger: Move ownership of perspective central widget to plugin It's only used in GammaRay currently, and with dynamic perspectives lifetime is better managed close to the code that knows how to (re-)construct the beasts. Change-Id: I9e8ebe2e93d749a62fb008f773f1702a4c0bab3c Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggermainwindow.cpp | 12 ++++++++---- src/plugins/debugger/debuggermainwindow.h | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 8f67819c0c2..1bbb40af7b2 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -463,7 +463,12 @@ Perspective::~Perspective() { foreach (const Operation &operation, m_operations) delete operation.widget; - delete m_centralWidget; +} + +void Perspective::setCentralWidget(QWidget *centralWidget) +{ + QTC_ASSERT(m_centralWidget == nullptr, return); + m_centralWidget = centralWidget; } QString Perspective::name() const @@ -523,9 +528,8 @@ Perspective::Operation::Operation(const QByteArray &dockId, QWidget *widget, con operationType(splitType), visibleByDefault(visibleByDefault), area(area) {} -Perspective::Perspective(const QString &name, const QVector &splits, - QWidget *centralWidget) - : m_name(name), m_operations(splits), m_centralWidget(centralWidget) +Perspective::Perspective(const QString &name, const QVector &splits) + : m_name(name), m_operations(splits) { for (const Operation &split : splits) m_docks.append(split.dockId); diff --git a/src/plugins/debugger/debuggermainwindow.h b/src/plugins/debugger/debuggermainwindow.h index c68cb437e54..af2610bd644 100644 --- a/src/plugins/debugger/debuggermainwindow.h +++ b/src/plugins/debugger/debuggermainwindow.h @@ -69,12 +69,12 @@ public: }; Perspective() = default; - // Takes ownership of \a centralWidget and all dock widgets in \a operations. + // Takes ownership of all dock widgets in \a operations. Perspective(const QString &name, - const QVector &operations = {}, - QWidget *centralWidget = nullptr); + const QVector &operations = {}); ~Perspective(); + void setCentralWidget(QWidget *centralWidget); void addOperation(const Operation &operation); void addWindow(QWidget *widget, OperationType op,