Debugger: Move ownership of perspective dock widgets to plugins

Similar to the previous patch, but affecting more plugins: with dynamic
perspectives lifetime is better managed close to the code that knows how
to (re-)construct the items.

Change-Id: I0e7bfcf769d198ec2afa88b972be900baa1b6a46
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2018-07-31 16:13:11 +02:00
parent 01e1653734
commit 01f2b982a2
11 changed files with 150 additions and 169 deletions

View File

@@ -203,7 +203,7 @@ ClangTidyClazyTool::ClangTidyClazyTool()
m_diagnosticFilterModel = new DiagnosticFilterModel(this); m_diagnosticFilterModel = new DiagnosticFilterModel(this);
m_diagnosticFilterModel->setSourceModel(m_diagnosticModel); m_diagnosticFilterModel->setSourceModel(m_diagnosticModel);
m_diagnosticView = new DiagnosticView; m_diagnosticView = std::make_unique<DiagnosticView>();
initDiagnosticView(); initDiagnosticView();
m_diagnosticView->setModel(m_diagnosticFilterModel); m_diagnosticView->setModel(m_diagnosticFilterModel);
m_diagnosticView->setObjectName(QLatin1String("ClangTidyClazyIssuesView")); m_diagnosticView->setObjectName(QLatin1String("ClangTidyClazyIssuesView"));
@@ -226,7 +226,7 @@ ClangTidyClazyTool::ClangTidyClazyTool()
action->setDisabled(true); action->setDisabled(true);
action->setIcon(Utils::Icons::PREV_TOOLBAR.icon()); action->setIcon(Utils::Icons::PREV_TOOLBAR.icon());
action->setToolTip(tr("Go to previous diagnostic.")); action->setToolTip(tr("Go to previous diagnostic."));
connect(action, &QAction::triggered, m_diagnosticView, &DetailedErrorView::goBack); connect(action, &QAction::triggered, m_diagnosticView.get(), &DetailedErrorView::goBack);
m_goBack = action; m_goBack = action;
// Go to next diagnostic // Go to next diagnostic
@@ -234,7 +234,7 @@ ClangTidyClazyTool::ClangTidyClazyTool()
action->setDisabled(true); action->setDisabled(true);
action->setIcon(Utils::Icons::NEXT_TOOLBAR.icon()); action->setIcon(Utils::Icons::NEXT_TOOLBAR.icon());
action->setToolTip(tr("Go to next diagnostic.")); action->setToolTip(tr("Go to next diagnostic."));
connect(action, &QAction::triggered, m_diagnosticView, &DetailedErrorView::goNext); connect(action, &QAction::triggered, m_diagnosticView.get(), &DetailedErrorView::goNext);
m_goNext = action; m_goNext = action;
// Filter line edit // Filter line edit
@@ -254,7 +254,7 @@ ClangTidyClazyTool::ClangTidyClazyTool()
&ClangToolsDiagnosticModel::fixItsToApplyCountChanged, &ClangToolsDiagnosticModel::fixItsToApplyCountChanged,
[this](int c) { [this](int c) {
m_applyFixitsButton->setEnabled(c); m_applyFixitsButton->setEnabled(c);
static_cast<DiagnosticView *>(m_diagnosticView)->setSelectedFixItsCount(c); static_cast<DiagnosticView *>(m_diagnosticView.get())->setSelectedFixItsCount(c);
}); });
connect(m_applyFixitsButton, &QToolButton::clicked, [this]() { connect(m_applyFixitsButton, &QToolButton::clicked, [this]() {
QVector<DiagnosticItem *> diagnosticItems; QVector<DiagnosticItem *> diagnosticItems;
@@ -269,10 +269,9 @@ ClangTidyClazyTool::ClangTidyClazyTool()
const QString toolTip = tr("Clang-Tidy and Clazy use a customized Clang executable from the " const QString toolTip = tr("Clang-Tidy and Clazy use a customized Clang executable from the "
"Clang project to search for errors and warnings."); "Clang project to search for errors and warnings.");
Debugger::registerPerspective(ClangTidyClazyPerspectiveId, new Perspective( auto perspective = new Perspective(tr("Clang-Tidy and Clazy"));
tr("Clang-Tidy and Clazy"), perspective->addWindow(m_diagnosticView.get(), Perspective::SplitVertical, nullptr);
{{ClangTidyClazyDockId, m_diagnosticView, {}, Perspective::SplitVertical}} Debugger::registerPerspective(ClangTidyClazyPerspectiveId, perspective);
));
action = new QAction(tr("Clang-Tidy and Clazy..."), this); action = new QAction(tr("Clang-Tidy and Clazy..."), this);
action->setToolTip(toolTip); action->setToolTip(toolTip);

View File

@@ -39,7 +39,6 @@ namespace Internal {
class DiagnosticFilterModel; class DiagnosticFilterModel;
const char ClangTidyClazyPerspectiveId[] = "ClangTidyClazy.Perspective"; const char ClangTidyClazyPerspectiveId[] = "ClangTidyClazy.Perspective";
const char ClangTidyClazyDockId[] = "ClangTidyClazy.Dock";
class ClangTidyClazyTool final : public ClangTool class ClangTidyClazyTool final : public ClangTool
{ {

View File

@@ -98,6 +98,8 @@ ClangTool::ClangTool(const QString &name)
m_stopAction = Debugger::createStopAction(); m_stopAction = Debugger::createStopAction();
} }
ClangTool::~ClangTool() = default;
FileInfos ClangTool::collectFileInfos(Project *project, bool askUserForFileSelection) const FileInfos ClangTool::collectFileInfos(Project *project, bool askUserForFileSelection) const
{ {
auto projectInfo = CppTools::CppModelManager::instance()->projectInfo(project); auto projectInfo = CppTools::CppModelManager::instance()->projectInfo(project);

View File

@@ -44,7 +44,7 @@ class ClangTool : public QObject
public: public:
ClangTool(const QString &name); ClangTool(const QString &name);
virtual ~ClangTool() = default; virtual ~ClangTool();
virtual void startTool(bool askUserForFileSelection) = 0; virtual void startTool(bool askUserForFileSelection) = 0;
@@ -72,7 +72,7 @@ protected:
void initDiagnosticView(); void initDiagnosticView();
ClangToolsDiagnosticModel *m_diagnosticModel = nullptr; ClangToolsDiagnosticModel *m_diagnosticModel = nullptr;
Debugger::DetailedErrorView *m_diagnosticView = nullptr; std::unique_ptr<Debugger::DetailedErrorView> m_diagnosticView;
QAction *m_startAction = nullptr; QAction *m_startAction = nullptr;
QAction *m_stopAction = nullptr; QAction *m_stopAction = nullptr;

View File

@@ -158,11 +158,6 @@ void DebuggerMainWindow::showStatusMessage(const QString &message, int timeoutMS
m_statusLabel->showStatusMessage(message, timeoutMS); m_statusLabel->showStatusMessage(message, timeoutMS);
} }
QDockWidget *DebuggerMainWindow::dockWidget(const QByteArray &dockId) const
{
return m_dockForDockId.value(dockId);
}
void DebuggerMainWindow::raiseDock(const QByteArray &dockId) void DebuggerMainWindow::raiseDock(const QByteArray &dockId)
{ {
QDockWidget *dock = m_dockForDockId.value(dockId); QDockWidget *dock = m_dockForDockId.value(dockId);
@@ -339,14 +334,17 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId,
// Clean up old perspective. // Clean up old perspective.
if (!m_currentPerspectiveId.isEmpty()) { if (!m_currentPerspectiveId.isEmpty()) {
savePerspectiveHelper(m_currentPerspectiveId); savePerspectiveHelper(m_currentPerspectiveId);
foreach (QDockWidget *dockWidget, m_dockForDockId) { for (QDockWidget *dock : m_dockForDockId) {
QTC_ASSERT(dockWidget, continue); QTC_ASSERT(dock, continue);
dockWidget->setFloating(false); dock->setFloating(false);
removeDockWidget(dockWidget); removeDockWidget(dock);
dockWidget->hide(); dock->setParent(nullptr);
// Prevent saveState storing the data of the wrong children. dock->widget()->setParent(nullptr);
dockWidget->setParent(nullptr); ActionManager::unregisterAction(dock->toggleViewAction(),
Id("Dock.").withSuffix(dock->objectName()));
delete dock;
} }
m_dockForDockId.clear();
ICore::removeAdditionalContext(Context(Id::fromName(m_currentPerspectiveId))); ICore::removeAdditionalContext(Context(Id::fromName(m_currentPerspectiveId)));
const Perspective *perspective = m_perspectiveForPerspectiveId.value(m_currentPerspectiveId); const Perspective *perspective = m_perspectiveForPerspectiveId.value(m_currentPerspectiveId);
@@ -372,11 +370,14 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId,
} }
QTC_ASSERT(perspective, return); QTC_ASSERT(perspective, return);
perspective->aboutToActivate(); perspective->aboutToActivate();
for (const Perspective::Operation &operation : perspective->operations()) { for (const Perspective::Operation &op : perspective->m_operations) {
QDockWidget *dock = m_dockForDockId.value(operation.dockId); QTC_ASSERT(op.widget, continue);
const QByteArray dockId = op.widget->objectName().toUtf8();
QDockWidget *dock = m_dockForDockId.value(dockId);
if (!dock) { if (!dock) {
QTC_CHECK(!operation.widget->objectName().isEmpty()); QTC_CHECK(!dockId.isEmpty());
dock = registerDockWidget(operation.dockId, operation.widget); dock = addDockForWidget(op.widget);
m_dockForDockId[dockId] = dock;
QAction *toggleViewAction = dock->toggleViewAction(); QAction *toggleViewAction = dock->toggleViewAction();
toggleViewAction->setText(dock->windowTitle()); toggleViewAction->setText(dock->windowTitle());
@@ -390,16 +391,16 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId,
} }
// Restore parent/child relation, so that the widget hierarchy is clear. // Restore parent/child relation, so that the widget hierarchy is clear.
dock->setParent(this); dock->setParent(this);
if (operation.operationType == Perspective::Raise) { if (op.operationType == Perspective::Raise) {
dock->raise(); dock->raise();
continue; continue;
} }
addDockWidget(operation.area, dock); addDockWidget(op.area, dock);
QDockWidget *anchor = m_dockForDockId.value(operation.anchorDockId); QDockWidget *anchor = m_dockForDockId.value(op.anchorDockId);
if (!anchor && operation.area == Qt::BottomDockWidgetArea) if (!anchor && op.area == Qt::BottomDockWidgetArea)
anchor = m_toolbarDock; anchor = m_toolbarDock;
if (anchor) { if (anchor) {
switch (operation.operationType) { switch (op.operationType) {
case Perspective::AddToTab: case Perspective::AddToTab:
tabifyDockWidget(anchor, dock); tabifyDockWidget(anchor, dock);
break; break;
@@ -413,7 +414,7 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId,
break; break;
} }
} }
if (!operation.visibleByDefault) if (!op.visibleByDefault)
dock->hide(); dock->hide();
else else
dock->show(); dock->show();
@@ -451,18 +452,8 @@ void DebuggerMainWindow::savePerspectiveHelper(const QByteArray &perspectiveId)
settings->setValue(QLatin1String(LAST_PERSPECTIVE_KEY), perspectiveId); settings->setValue(QLatin1String(LAST_PERSPECTIVE_KEY), perspectiveId);
} }
QDockWidget *DebuggerMainWindow::registerDockWidget(const QByteArray &dockId, QWidget *widget)
{
QTC_ASSERT(!widget->objectName().isEmpty(), return nullptr);
QDockWidget *dockWidget = addDockForWidget(widget);
m_dockForDockId[dockId] = dockWidget;
return dockWidget;
}
Perspective::~Perspective() Perspective::~Perspective()
{ {
foreach (const Operation &operation, m_operations)
delete operation.widget;
} }
void Perspective::setCentralWidget(QWidget *centralWidget) void Perspective::setCentralWidget(QWidget *centralWidget)
@@ -521,34 +512,22 @@ void ToolbarDescription::addWidget(QWidget *widget)
m_widgets.append(widget); m_widgets.append(widget);
} }
Perspective::Operation::Operation(const QByteArray &dockId, QWidget *widget, const QByteArray &anchorDockId, Perspective::Perspective(const QString &name)
Perspective::OperationType splitType, bool visibleByDefault, : m_name(name)
Qt::DockWidgetArea area)
: dockId(dockId), widget(widget), anchorDockId(anchorDockId),
operationType(splitType), visibleByDefault(visibleByDefault), area(area)
{}
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);
} }
void Perspective::addOperation(const Operation &operation) void Perspective::addWindow(QWidget *widget, OperationType type, QWidget *anchorWidget,
bool visibleByDefault, Qt::DockWidgetArea area)
{ {
m_docks.append(operation.dockId); Operation op;
m_operations.append(operation); op.widget = widget;
} if (anchorWidget)
op.anchorDockId = anchorWidget->objectName().toUtf8();
void Perspective::addWindow(QWidget *widget, op.operationType = type;
Perspective::OperationType op, op.visibleByDefault = visibleByDefault;
bool visibleByDefault, op.area = area;
Qt::DockWidgetArea area) m_operations.append(op);
{
const QByteArray dockId = widget->objectName().toUtf8();
QTC_CHECK(!dockId.isEmpty());
m_operations.append({dockId, widget, {}, op, visibleByDefault, area});
} }
} // Utils } // Utils

View File

@@ -50,39 +50,17 @@ class DEBUGGER_EXPORT Perspective
public: public:
enum OperationType { SplitVertical, SplitHorizontal, AddToTab, Raise }; enum OperationType { SplitVertical, SplitHorizontal, AddToTab, Raise };
class DEBUGGER_EXPORT Operation
{
public:
Operation() = default;
Operation(const QByteArray &dockId, QWidget *widget,
const QByteArray &anchorDockId,
OperationType operationType,
bool visibleByDefault = true,
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
QByteArray dockId;
QPointer<QWidget> widget;
QByteArray anchorDockId;
OperationType operationType = Raise;
bool visibleByDefault = true;
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea;
};
Perspective() = default; Perspective() = default;
// Takes ownership of all dock widgets in \a operations. explicit Perspective(const QString &name);
Perspective(const QString &name,
const QVector<Operation> &operations = {});
~Perspective(); ~Perspective();
void setCentralWidget(QWidget *centralWidget); void setCentralWidget(QWidget *centralWidget);
void addOperation(const Operation &operation);
void addWindow(QWidget *widget, void addWindow(QWidget *widget,
OperationType op, OperationType op,
QWidget *anchorWidget,
bool visibleByDefault = true, bool visibleByDefault = true,
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea); Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
QVector<Operation> operations() const { return m_operations; }
QVector<QByteArray> docks() const { return m_docks; }
QWidget *centralWidget() const { return m_centralWidget; } QWidget *centralWidget() const { return m_centralWidget; }
QString name() const; QString name() const;
@@ -99,9 +77,20 @@ private:
Perspective(const Perspective &) = delete; Perspective(const Perspective &) = delete;
void operator=(const Perspective &) = delete; void operator=(const Perspective &) = delete;
friend class DebuggerMainWindow;
class Operation
{
public:
QPointer<QWidget> widget;
QByteArray anchorDockId;
OperationType operationType = Raise;
bool visibleByDefault = true;
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea;
};
QString m_name; QString m_name;
QByteArray m_parentPerspective; QByteArray m_parentPerspective;
QVector<QByteArray> m_docks;
QVector<Operation> m_operations; QVector<Operation> m_operations;
QPointer<QWidget> m_centralWidget; QPointer<QWidget> m_centralWidget;
Callback m_aboutToActivateCallback; Callback m_aboutToActivateCallback;
@@ -141,7 +130,6 @@ public:
void finalizeSetup(); void finalizeSetup();
void showStatusMessage(const QString &message, int timeoutMS); void showStatusMessage(const QString &message, int timeoutMS);
QDockWidget *dockWidget(const QByteArray &dockId) const;
void raiseDock(const QByteArray &dockId); void raiseDock(const QByteArray &dockId);
QByteArray currentPerspective() const { return m_currentPerspectiveId; } QByteArray currentPerspective() const { return m_currentPerspectiveId; }
QStackedWidget *centralWidgetStack() const { return m_centralWidgetStack; } QStackedWidget *centralWidgetStack() const { return m_centralWidgetStack; }
@@ -153,7 +141,6 @@ public:
private: private:
void closeEvent(QCloseEvent *) final { savePerspectiveHelper(m_currentPerspectiveId); } void closeEvent(QCloseEvent *) final { savePerspectiveHelper(m_currentPerspectiveId); }
QDockWidget *registerDockWidget(const QByteArray &dockId, QWidget *widget);
void loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings = true); void loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings = true);
void savePerspectiveHelper(const QByteArray &perspectiveId); void savePerspectiveHelper(const QByteArray &perspectiveId);
void increaseChooserWidthIfNecessary(const QString &visibleName); void increaseChooserWidthIfNecessary(const QString &visibleName);

View File

@@ -1022,20 +1022,21 @@ public:
BaseTreeView *m_stackView = nullptr; BaseTreeView *m_stackView = nullptr;
BaseTreeView *m_threadsView = nullptr; BaseTreeView *m_threadsView = nullptr;
QWidget *m_breakWindow = nullptr;
BreakHandler *m_breakHandler = nullptr; BreakHandler *m_breakHandler = nullptr;
QWidget *m_returnWindow = nullptr;
QWidget *m_localsWindow = nullptr; QPointer<QWidget> m_returnWindow;
QWidget *m_watchersWindow = nullptr; QPointer<QWidget> m_localsWindow;
QWidget *m_inspectorWindow = nullptr; QPointer<QWidget> m_watchersWindow;
QWidget *m_registerWindow = nullptr; QPointer<QWidget> m_inspectorWindow;
QWidget *m_modulesWindow = nullptr; QPointer<LocalsAndInspectorWindow> m_localsAndInspectorWindow;
QWidget *m_snapshotWindow = nullptr; QPointer<QWidget> m_breakWindow;
QWidget *m_sourceFilesWindow = nullptr; QPointer<QWidget> m_registerWindow;
QWidget *m_stackWindow = nullptr; QPointer<QWidget> m_modulesWindow;
QWidget *m_threadsWindow = nullptr; QPointer<QWidget> m_snapshotWindow;
LogWindow *m_logWindow = nullptr; QPointer<QWidget> m_sourceFilesWindow;
LocalsAndInspectorWindow *m_localsAndInspectorWindow = nullptr; QPointer<QWidget> m_stackWindow;
QPointer<QWidget> m_threadsWindow;
QPointer<LogWindow> m_logWindow;
bool m_busy = false; bool m_busy = false;
QString m_lastPermanentStatusMessage; QString m_lastPermanentStatusMessage;
@@ -1088,6 +1089,20 @@ DebuggerPluginPrivate::~DebuggerPluginPrivate()
delete m_breakHandler; delete m_breakHandler;
m_breakHandler = nullptr; m_breakHandler = nullptr;
delete m_returnWindow;
delete m_localsWindow;
delete m_watchersWindow;
delete m_inspectorWindow;
delete m_localsAndInspectorWindow;
delete m_breakWindow;
delete m_registerWindow;
delete m_modulesWindow;
delete m_snapshotWindow;
delete m_sourceFilesWindow;
delete m_stackWindow;
delete m_threadsWindow;
delete m_logWindow;
} }
DebuggerEngine *DebuggerPluginPrivate::dummyEngine() DebuggerEngine *DebuggerPluginPrivate::dummyEngine()
@@ -1341,8 +1356,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
this, [this](bool on) { m_breakView->setColumnHidden(BreakpointAddressColumn, !on); }); this, [this](bool on) { m_breakView->setColumnHidden(BreakpointAddressColumn, !on); });
m_breakView->setSettings(settings, "Debugger.BreakWindow"); m_breakView->setSettings(settings, "Debugger.BreakWindow");
m_breakView->setModel(m_breakHandler->model()); m_breakView->setModel(m_breakHandler->model());
m_breakWindow = addSearch(m_breakView, tr("&Breakpoints"), DOCKWIDGET_BREAK);
m_breakView->setRootIsDecorated(true); m_breakView->setRootIsDecorated(true);
m_breakWindow = addSearch(m_breakView, tr("&Breakpoints"), DOCKWIDGET_BREAK);
m_modulesView = new BaseTreeView; m_modulesView = new BaseTreeView;
m_modulesView->setSortingEnabled(true); m_modulesView->setSortingEnabled(true);
@@ -1486,8 +1501,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
ActionContainer *debugMenu = ActionManager::actionContainer(PE::M_DEBUG); ActionContainer *debugMenu = ActionManager::actionContainer(PE::M_DEBUG);
m_localsAndInspectorWindow = new LocalsAndInspectorWindow( m_localsAndInspectorWindow = new LocalsAndInspectorWindow
m_localsWindow, m_inspectorWindow, m_returnWindow); (m_localsWindow, m_inspectorWindow, m_returnWindow);
m_localsAndInspectorWindow->setObjectName(DOCKWIDGET_LOCALS_AND_INSPECTOR); m_localsAndInspectorWindow->setObjectName(DOCKWIDGET_LOCALS_AND_INSPECTOR);
m_localsAndInspectorWindow->setWindowTitle(m_localsWindow->windowTitle()); m_localsAndInspectorWindow->setWindowTitle(m_localsWindow->windowTitle());
@@ -1830,25 +1845,26 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
// qmlToolbar.addAction(qmlSelectDummyAction, Icons::SELECT_TOOLBAR.icon()); // qmlToolbar.addAction(qmlSelectDummyAction, Icons::SELECT_TOOLBAR.icon());
// qmlToolbar.addWidget(new StyledSeparator); // qmlToolbar.addWidget(new StyledSeparator);
auto createBasePerspective = [this] { return new Perspective({}, { auto createBasePerspective = [this] {
{DOCKWIDGET_STACK, m_stackWindow, {}, Perspective::SplitVertical}, auto perspective = new Perspective;
{DOCKWIDGET_BREAK, m_breakWindow, DOCKWIDGET_STACK, Perspective::SplitHorizontal}, perspective->addWindow(m_stackWindow, Perspective::SplitVertical, nullptr);
{DOCKWIDGET_THREADS, m_threadsWindow, DOCKWIDGET_BREAK, Perspective::AddToTab, false}, perspective->addWindow(m_breakWindow, Perspective::SplitHorizontal, m_stackWindow);
{DOCKWIDGET_MODULES, m_modulesWindow, DOCKWIDGET_THREADS, Perspective::AddToTab, false}, perspective->addWindow(m_threadsWindow, Perspective::AddToTab, m_breakWindow, false);
{DOCKWIDGET_SOURCE_FILES, m_sourceFilesWindow, DOCKWIDGET_MODULES, Perspective::AddToTab, false}, perspective->addWindow(m_modulesWindow, Perspective::AddToTab, m_threadsWindow, false);
{DOCKWIDGET_SNAPSHOTS, m_snapshotWindow, DOCKWIDGET_SOURCE_FILES, Perspective::AddToTab, false}, perspective->addWindow(m_sourceFilesWindow, Perspective::AddToTab, m_modulesWindow, false);
{DOCKWIDGET_LOCALS_AND_INSPECTOR, m_localsAndInspectorWindow, {}, Perspective::AddToTab, true, perspective->addWindow(m_snapshotWindow, Perspective::AddToTab, m_sourceFilesWindow, false);
Qt::RightDockWidgetArea}, perspective->addWindow(m_localsAndInspectorWindow, Perspective::AddToTab, nullptr, true,
{DOCKWIDGET_WATCHERS, m_watchersWindow, DOCKWIDGET_LOCALS_AND_INSPECTOR, Perspective::AddToTab, true, Qt::RightDockWidgetArea);
Qt::RightDockWidgetArea}, perspective->addWindow(m_watchersWindow, Perspective::AddToTab, m_localsAndInspectorWindow, true,
{DOCKWIDGET_OUTPUT, m_logWindow, {}, Perspective::AddToTab, false, Qt::TopDockWidgetArea}, Qt::RightDockWidgetArea);
{DOCKWIDGET_BREAK, nullptr, {}, Perspective::Raise} perspective->addWindow(m_logWindow, Perspective::AddToTab, nullptr, false, Qt::TopDockWidgetArea);
}); }; perspective->addWindow(m_breakWindow, Perspective::Raise, nullptr);
return perspective;
};
Perspective *cppPerspective = createBasePerspective(); Perspective *cppPerspective = createBasePerspective();
cppPerspective->setName(tr("Debugger")); cppPerspective->setName(tr("Debugger"));
cppPerspective->addOperation({DOCKWIDGET_REGISTER, m_registerWindow, DOCKWIDGET_SNAPSHOTS, cppPerspective->addWindow(m_registerWindow, Perspective::AddToTab, m_snapshotWindow, false);
Perspective::AddToTab, false});
Debugger::registerToolbar(CppPerspectiveId, toolbar); Debugger::registerToolbar(CppPerspectiveId, toolbar);
Debugger::registerPerspective(CppPerspectiveId, cppPerspective); Debugger::registerPerspective(CppPerspectiveId, cppPerspective);

View File

@@ -83,24 +83,28 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
m_flameGraphView = new FlameGraphView(m_profilerModelManager); m_flameGraphView = new FlameGraphView(m_profilerModelManager);
prepareEventsView(m_flameGraphView); prepareEventsView(m_flameGraphView);
QByteArray anchorDockId; QWidget *anchor = nullptr;
if (m_traceView->isUsable()) { if (m_traceView->isUsable()) {
anchorDockId = m_traceView->objectName().toLatin1(); anchor = m_traceView;
perspective->addOperation({anchorDockId, m_traceView, {}, Perspective::SplitVertical}); perspective->addWindow(m_traceView, Perspective::SplitVertical, nullptr);
perspective->addOperation({m_flameGraphView->objectName().toLatin1(), m_flameGraphView, perspective->addWindow(m_flameGraphView, Perspective::AddToTab, anchor);
anchorDockId, Perspective::AddToTab});
} else { } else {
anchorDockId = m_flameGraphView->objectName().toLatin1(); anchor = m_flameGraphView;
perspective->addOperation({anchorDockId, m_flameGraphView, {}, perspective->addWindow(m_flameGraphView, Perspective::SplitVertical, nullptr);
Perspective::SplitVertical});
} }
perspective->addOperation({m_statisticsView->objectName().toLatin1(), m_statisticsView, perspective->addWindow(m_statisticsView, Perspective::AddToTab, anchor);
anchorDockId, Perspective::AddToTab}); perspective->addWindow(anchor, Perspective::Raise, nullptr);
perspective->addOperation({anchorDockId, nullptr, {}, Perspective::Raise});
Debugger::registerPerspective(Constants::QmlProfilerPerspectiveId, perspective); Debugger::registerPerspective(Constants::QmlProfilerPerspectiveId, perspective);
} }
QmlProfilerViewManager::~QmlProfilerViewManager()
{
delete m_traceView;
delete m_flameGraphView;
delete m_statisticsView;
}
void QmlProfilerViewManager::clear() void QmlProfilerViewManager::clear()
{ {
m_traceView->clear(); m_traceView->clear();

View File

@@ -44,6 +44,7 @@ public:
QmlProfilerViewManager(QObject *parent, QmlProfilerViewManager(QObject *parent,
QmlProfilerModelManager *modelManager, QmlProfilerModelManager *modelManager,
QmlProfilerStateManager *profilerState); QmlProfilerStateManager *profilerState);
~QmlProfilerViewManager();
QmlProfilerTraceView *traceView() const { return m_traceView; } QmlProfilerTraceView *traceView() const { return m_traceView; }
QmlProfilerStatisticsView *statisticsView() const { return m_statisticsView; } QmlProfilerStatisticsView *statisticsView() const { return m_statisticsView; }

View File

@@ -105,11 +105,6 @@ namespace Internal {
const char CallgrindPerspectiveId[] = "Callgrind.Perspective"; const char CallgrindPerspectiveId[] = "Callgrind.Perspective";
const char CallgrindLocalActionId[] = "Callgrind.Local.Action"; const char CallgrindLocalActionId[] = "Callgrind.Local.Action";
const char CallgrindRemoteActionId[] = "Callgrind.Remote.Action"; const char CallgrindRemoteActionId[] = "Callgrind.Remote.Action";
const char CallgrindCallersDockId[] = "Callgrind.Callers.Dock";
const char CallgrindCalleesDockId[] = "Callgrind.Callees.Dock";
const char CallgrindFlatDockId[] = "Callgrind.Flat.Dock";
const char CallgrindVisualizationDockId[] = "Callgrind.Visualization.Dock";
const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode"; const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode";
class CallgrindTool : public QObject class CallgrindTool : public QObject
@@ -187,10 +182,10 @@ public:
QSortFilterProxyModel m_calleesProxy; QSortFilterProxyModel m_calleesProxy;
// Callgrind widgets // Callgrind widgets
CostView *m_flatView = nullptr; std::unique_ptr<CostView> m_flatView;
CostView *m_callersView = nullptr; std::unique_ptr<CostView> m_callersView;
CostView *m_calleesView = nullptr; std::unique_ptr<CostView> m_calleesView;
Visualisation *m_visualization = nullptr; std::unique_ptr<Visualisation> m_visualization;
// Navigation // Navigation
QAction *m_goBack = nullptr; QAction *m_goBack = nullptr;
@@ -312,15 +307,15 @@ CallgrindTool::CallgrindTool()
// //
// DockWidgets // DockWidgets
// //
m_visualization = new Visualisation; m_visualization = std::make_unique<Visualisation>();
m_visualization->setFrameStyle(QFrame::NoFrame); m_visualization->setFrameStyle(QFrame::NoFrame);
m_visualization->setObjectName(QLatin1String("Valgrind.CallgrindTool.Visualisation")); m_visualization->setObjectName(QLatin1String("Valgrind.CallgrindTool.Visualisation"));
m_visualization->setWindowTitle(tr("Visualization")); m_visualization->setWindowTitle(tr("Visualization"));
m_visualization->setModel(&m_dataModel); m_visualization->setModel(&m_dataModel);
connect(m_visualization, &Visualisation::functionActivated, connect(m_visualization.get(), &Visualisation::functionActivated,
this, &CallgrindTool::visualisationFunctionSelected); this, &CallgrindTool::visualisationFunctionSelected);
m_callersView = new CostView; m_callersView = std::make_unique<CostView>();
m_callersView->setObjectName(QLatin1String("Valgrind.CallgrindTool.CallersView")); m_callersView->setObjectName(QLatin1String("Valgrind.CallgrindTool.CallersView"));
m_callersView->setWindowTitle(tr("Callers")); m_callersView->setWindowTitle(tr("Callers"));
m_callersView->setSettings(coreSettings, "Valgrind.CallgrindTool.CallersView"); m_callersView->setSettings(coreSettings, "Valgrind.CallgrindTool.CallersView");
@@ -330,10 +325,10 @@ CallgrindTool::CallgrindTool()
m_callersProxy.setSourceModel(&m_callersModel); m_callersProxy.setSourceModel(&m_callersModel);
m_callersView->setModel(&m_callersProxy); m_callersView->setModel(&m_callersProxy);
m_callersView->hideColumn(CallModel::CalleeColumn); m_callersView->hideColumn(CallModel::CalleeColumn);
connect(m_callersView, &QAbstractItemView::activated, connect(m_callersView.get(), &QAbstractItemView::activated,
this, &CallgrindTool::callerFunctionSelected); this, &CallgrindTool::callerFunctionSelected);
m_calleesView = new CostView; m_calleesView = std::make_unique<CostView>();
m_calleesView->setObjectName(QLatin1String("Valgrind.CallgrindTool.CalleesView")); m_calleesView->setObjectName(QLatin1String("Valgrind.CallgrindTool.CalleesView"));
m_calleesView->setWindowTitle(tr("Callees")); m_calleesView->setWindowTitle(tr("Callees"));
m_calleesView->setSettings(coreSettings, "Valgrind.CallgrindTool.CalleesView"); m_calleesView->setSettings(coreSettings, "Valgrind.CallgrindTool.CalleesView");
@@ -343,10 +338,10 @@ CallgrindTool::CallgrindTool()
m_calleesProxy.setSourceModel(&m_calleesModel); m_calleesProxy.setSourceModel(&m_calleesModel);
m_calleesView->setModel(&m_calleesProxy); m_calleesView->setModel(&m_calleesProxy);
m_calleesView->hideColumn(CallModel::CallerColumn); m_calleesView->hideColumn(CallModel::CallerColumn);
connect(m_calleesView, &QAbstractItemView::activated, connect(m_calleesView.get(), &QAbstractItemView::activated,
this, &CallgrindTool::calleeFunctionSelected); this, &CallgrindTool::calleeFunctionSelected);
m_flatView = new CostView; m_flatView = std::make_unique<CostView>();
m_flatView->setObjectName(QLatin1String("Valgrind.CallgrindTool.FlatView")); m_flatView->setObjectName(QLatin1String("Valgrind.CallgrindTool.FlatView"));
m_flatView->setWindowTitle(tr("Functions")); m_flatView->setWindowTitle(tr("Functions"));
m_flatView->setSettings(coreSettings, "Valgrind.CallgrindTool.FlatView"); m_flatView->setSettings(coreSettings, "Valgrind.CallgrindTool.FlatView");
@@ -354,7 +349,7 @@ CallgrindTool::CallgrindTool()
m_flatView->setFrameStyle(QFrame::NoFrame); m_flatView->setFrameStyle(QFrame::NoFrame);
m_flatView->setAttribute(Qt::WA_MacShowFocusRect, false); m_flatView->setAttribute(Qt::WA_MacShowFocusRect, false);
m_flatView->setModel(&m_proxyModel); m_flatView->setModel(&m_proxyModel);
connect(m_flatView, &QAbstractItemView::activated, connect(m_flatView.get(), &QAbstractItemView::activated,
this, &CallgrindTool::dataFunctionSelected); this, &CallgrindTool::dataFunctionSelected);
updateCostFormat(); updateCostFormat();
@@ -511,13 +506,13 @@ CallgrindTool::CallgrindTool()
toolbar.addWidget(m_searchFilter); toolbar.addWidget(m_searchFilter);
Debugger::registerToolbar(CallgrindPerspectiveId, toolbar); Debugger::registerToolbar(CallgrindPerspectiveId, toolbar);
Debugger::registerPerspective(CallgrindPerspectiveId, new Perspective(tr("Callgrind"), { auto perspective = new Perspective(tr("Callgrind"));
{CallgrindFlatDockId, m_flatView, {}, Perspective::SplitVertical}, perspective->addWindow(m_flatView.get(), Perspective::SplitVertical, nullptr);
{CallgrindCalleesDockId, m_calleesView, {}, Perspective::SplitVertical}, perspective->addWindow(m_calleesView.get(), Perspective::SplitVertical, nullptr);
{CallgrindCallersDockId, m_callersView, CallgrindCalleesDockId, Perspective::SplitHorizontal}, perspective->addWindow(m_callersView.get(), Perspective::SplitHorizontal, m_calleesView.get());
{CallgrindVisualizationDockId, m_visualization, {}, Perspective::SplitVertical, perspective->addWindow(m_visualization.get(), Perspective::SplitVertical, nullptr,
false, Qt::RightDockWidgetArea} false, Qt::RightDockWidgetArea);
})); Debugger::registerPerspective(CallgrindPerspectiveId, perspective);
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions, connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
this, &CallgrindTool::updateRunActions); this, &CallgrindTool::updateRunActions);

View File

@@ -118,7 +118,6 @@ const char MEMCHECK_RUN_MODE[] = "MemcheckTool.MemcheckRunMode";
const char MEMCHECK_WITH_GDB_RUN_MODE[] = "MemcheckTool.MemcheckWithGdbRunMode"; const char MEMCHECK_WITH_GDB_RUN_MODE[] = "MemcheckTool.MemcheckWithGdbRunMode";
const char MemcheckPerspectiveId[] = "Memcheck.Perspective"; const char MemcheckPerspectiveId[] = "Memcheck.Perspective";
const char MemcheckErrorDockId[] = "Memcheck.Dock.Error";
class MemcheckToolRunner : public ValgrindToolRunner class MemcheckToolRunner : public ValgrindToolRunner
@@ -425,7 +424,7 @@ private:
Valgrind::XmlProtocol::ErrorListModel m_errorModel; Valgrind::XmlProtocol::ErrorListModel m_errorModel;
MemcheckErrorFilterProxyModel m_errorProxyModel; MemcheckErrorFilterProxyModel m_errorProxyModel;
MemcheckErrorView *m_errorView = 0; std::unique_ptr<MemcheckErrorView> m_errorView;
QList<QAction *> m_errorFilterActions; QList<QAction *> m_errorFilterActions;
QAction *m_filterProjectAction; QAction *m_filterProjectAction;
@@ -540,7 +539,7 @@ MemcheckTool::MemcheckTool()
initKindFilterAction(a, { InvalidFree, MismatchedFree }); initKindFilterAction(a, { InvalidFree, MismatchedFree });
m_errorFilterActions.append(a); m_errorFilterActions.append(a);
m_errorView = new MemcheckErrorView; m_errorView = std::make_unique<MemcheckErrorView>();
m_errorView->setObjectName(QLatin1String("MemcheckErrorView")); m_errorView->setObjectName(QLatin1String("MemcheckErrorView"));
m_errorView->setFrameStyle(QFrame::NoFrame); m_errorView->setFrameStyle(QFrame::NoFrame);
m_errorView->setAttribute(Qt::WA_MacShowFocusRect, false); m_errorView->setAttribute(Qt::WA_MacShowFocusRect, false);
@@ -556,9 +555,9 @@ MemcheckTool::MemcheckTool()
m_errorView->setObjectName(QLatin1String("Valgrind.MemcheckTool.ErrorView")); m_errorView->setObjectName(QLatin1String("Valgrind.MemcheckTool.ErrorView"));
m_errorView->setWindowTitle(tr("Memory Issues")); m_errorView->setWindowTitle(tr("Memory Issues"));
Debugger::registerPerspective(MemcheckPerspectiveId, new Perspective (tr("Memcheck"), { auto perspective = new Perspective(tr("Memcheck"));
{MemcheckErrorDockId, m_errorView, {}, Perspective::SplitVertical} perspective->addWindow(m_errorView.get(), Perspective::SplitVertical, nullptr);
})); Debugger::registerPerspective(MemcheckPerspectiveId, perspective);
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions, connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
this, &MemcheckTool::maybeActiveRunConfigurationChanged); this, &MemcheckTool::maybeActiveRunConfigurationChanged);
@@ -583,7 +582,7 @@ MemcheckTool::MemcheckTool()
action->setDisabled(true); action->setDisabled(true);
action->setIcon(Icons::PREV_TOOLBAR.icon()); action->setIcon(Icons::PREV_TOOLBAR.icon());
action->setToolTip(tr("Go to previous leak.")); action->setToolTip(tr("Go to previous leak."));
connect(action, &QAction::triggered, m_errorView, &MemcheckErrorView::goBack); connect(action, &QAction::triggered, m_errorView.get(), &MemcheckErrorView::goBack);
m_goBack = action; m_goBack = action;
// Go to next leak. // Go to next leak.
@@ -591,7 +590,7 @@ MemcheckTool::MemcheckTool()
action->setDisabled(true); action->setDisabled(true);
action->setIcon(Icons::NEXT_TOOLBAR.icon()); action->setIcon(Icons::NEXT_TOOLBAR.icon());
action->setToolTip(tr("Go to next leak.")); action->setToolTip(tr("Go to next leak."));
connect(action, &QAction::triggered, m_errorView, &MemcheckErrorView::goNext); connect(action, &QAction::triggered, m_errorView.get(), &MemcheckErrorView::goNext);
m_goNext = action; m_goNext = action;
auto filterButton = new QToolButton; auto filterButton = new QToolButton;