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 <christian.stenger@qt.io>
This commit is contained in:
hjk
2018-07-31 12:30:48 +02:00
parent ca42e48dac
commit 0c2bc9c2da
2 changed files with 11 additions and 7 deletions

View File

@@ -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<Operation> &splits,
QWidget *centralWidget)
: m_name(name), m_operations(splits), m_centralWidget(centralWidget)
Perspective::Perspective(const QString &name, const QVector<Operation> &splits)
: m_name(name), m_operations(splits)
{
for (const Operation &split : splits)
m_docks.append(split.dockId);

View File

@@ -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<Operation> &operations = {},
QWidget *centralWidget = nullptr);
const QVector<Operation> &operations = {});
~Perspective();
void setCentralWidget(QWidget *centralWidget);
void addOperation(const Operation &operation);
void addWindow(QWidget *widget,
OperationType op,