diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/clangtools/clangtidyclazytool.cpp | 15 | ||||
-rw-r--r-- | src/plugins/clangtools/clangtidyclazytool.h | 1 | ||||
-rw-r--r-- | src/plugins/clangtools/clangtool.cpp | 2 | ||||
-rw-r--r-- | src/plugins/clangtools/clangtool.h | 4 | ||||
-rw-r--r-- | src/plugins/debugger/debuggermainwindow.cpp | 91 | ||||
-rw-r--r-- | src/plugins/debugger/debuggermainwindow.h | 41 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 80 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp | 26 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerviewmanager.h | 1 | ||||
-rw-r--r-- | src/plugins/valgrind/callgrindtool.cpp | 43 | ||||
-rw-r--r-- | src/plugins/valgrind/memchecktool.cpp | 15 |
11 files changed, 150 insertions, 169 deletions
diff --git a/src/plugins/clangtools/clangtidyclazytool.cpp b/src/plugins/clangtools/clangtidyclazytool.cpp index d3f3d841b70..3e01f2dea02 100644 --- a/src/plugins/clangtools/clangtidyclazytool.cpp +++ b/src/plugins/clangtools/clangtidyclazytool.cpp @@ -203,7 +203,7 @@ ClangTidyClazyTool::ClangTidyClazyTool() m_diagnosticFilterModel = new DiagnosticFilterModel(this); m_diagnosticFilterModel->setSourceModel(m_diagnosticModel); - m_diagnosticView = new DiagnosticView; + m_diagnosticView = std::make_unique<DiagnosticView>(); initDiagnosticView(); m_diagnosticView->setModel(m_diagnosticFilterModel); m_diagnosticView->setObjectName(QLatin1String("ClangTidyClazyIssuesView")); @@ -226,7 +226,7 @@ ClangTidyClazyTool::ClangTidyClazyTool() action->setDisabled(true); action->setIcon(Utils::Icons::PREV_TOOLBAR.icon()); 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; // Go to next diagnostic @@ -234,7 +234,7 @@ ClangTidyClazyTool::ClangTidyClazyTool() action->setDisabled(true); action->setIcon(Utils::Icons::NEXT_TOOLBAR.icon()); 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; // Filter line edit @@ -254,7 +254,7 @@ ClangTidyClazyTool::ClangTidyClazyTool() &ClangToolsDiagnosticModel::fixItsToApplyCountChanged, [this](int 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]() { QVector<DiagnosticItem *> diagnosticItems; @@ -269,10 +269,9 @@ ClangTidyClazyTool::ClangTidyClazyTool() const QString toolTip = tr("Clang-Tidy and Clazy use a customized Clang executable from the " "Clang project to search for errors and warnings."); - Debugger::registerPerspective(ClangTidyClazyPerspectiveId, new Perspective( - tr("Clang-Tidy and Clazy"), - {{ClangTidyClazyDockId, m_diagnosticView, {}, Perspective::SplitVertical}} - )); + auto perspective = new Perspective(tr("Clang-Tidy and Clazy")); + perspective->addWindow(m_diagnosticView.get(), Perspective::SplitVertical, nullptr); + Debugger::registerPerspective(ClangTidyClazyPerspectiveId, perspective); action = new QAction(tr("Clang-Tidy and Clazy..."), this); action->setToolTip(toolTip); diff --git a/src/plugins/clangtools/clangtidyclazytool.h b/src/plugins/clangtools/clangtidyclazytool.h index 72832451d1f..2391afbe3a7 100644 --- a/src/plugins/clangtools/clangtidyclazytool.h +++ b/src/plugins/clangtools/clangtidyclazytool.h @@ -39,7 +39,6 @@ namespace Internal { class DiagnosticFilterModel; const char ClangTidyClazyPerspectiveId[] = "ClangTidyClazy.Perspective"; -const char ClangTidyClazyDockId[] = "ClangTidyClazy.Dock"; class ClangTidyClazyTool final : public ClangTool { diff --git a/src/plugins/clangtools/clangtool.cpp b/src/plugins/clangtools/clangtool.cpp index 248bee44ea0..dfc96585259 100644 --- a/src/plugins/clangtools/clangtool.cpp +++ b/src/plugins/clangtools/clangtool.cpp @@ -98,6 +98,8 @@ ClangTool::ClangTool(const QString &name) m_stopAction = Debugger::createStopAction(); } +ClangTool::~ClangTool() = default; + FileInfos ClangTool::collectFileInfos(Project *project, bool askUserForFileSelection) const { auto projectInfo = CppTools::CppModelManager::instance()->projectInfo(project); diff --git a/src/plugins/clangtools/clangtool.h b/src/plugins/clangtools/clangtool.h index 6363cedb641..385c63a5cc1 100644 --- a/src/plugins/clangtools/clangtool.h +++ b/src/plugins/clangtools/clangtool.h @@ -44,7 +44,7 @@ class ClangTool : public QObject public: ClangTool(const QString &name); - virtual ~ClangTool() = default; + virtual ~ClangTool(); virtual void startTool(bool askUserForFileSelection) = 0; @@ -72,7 +72,7 @@ protected: void initDiagnosticView(); ClangToolsDiagnosticModel *m_diagnosticModel = nullptr; - Debugger::DetailedErrorView *m_diagnosticView = nullptr; + std::unique_ptr<Debugger::DetailedErrorView> m_diagnosticView; QAction *m_startAction = nullptr; QAction *m_stopAction = nullptr; diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 1bbb40af7b2..dadea407597 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -158,11 +158,6 @@ void DebuggerMainWindow::showStatusMessage(const QString &message, int timeoutMS m_statusLabel->showStatusMessage(message, timeoutMS); } -QDockWidget *DebuggerMainWindow::dockWidget(const QByteArray &dockId) const -{ - return m_dockForDockId.value(dockId); -} - void DebuggerMainWindow::raiseDock(const QByteArray &dockId) { QDockWidget *dock = m_dockForDockId.value(dockId); @@ -339,14 +334,17 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId, // Clean up old perspective. if (!m_currentPerspectiveId.isEmpty()) { savePerspectiveHelper(m_currentPerspectiveId); - foreach (QDockWidget *dockWidget, m_dockForDockId) { - QTC_ASSERT(dockWidget, continue); - dockWidget->setFloating(false); - removeDockWidget(dockWidget); - dockWidget->hide(); - // Prevent saveState storing the data of the wrong children. - dockWidget->setParent(nullptr); + for (QDockWidget *dock : m_dockForDockId) { + QTC_ASSERT(dock, continue); + dock->setFloating(false); + removeDockWidget(dock); + dock->setParent(nullptr); + dock->widget()->setParent(nullptr); + ActionManager::unregisterAction(dock->toggleViewAction(), + Id("Dock.").withSuffix(dock->objectName())); + delete dock; } + m_dockForDockId.clear(); ICore::removeAdditionalContext(Context(Id::fromName(m_currentPerspectiveId))); const Perspective *perspective = m_perspectiveForPerspectiveId.value(m_currentPerspectiveId); @@ -372,11 +370,14 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId, } QTC_ASSERT(perspective, return); perspective->aboutToActivate(); - for (const Perspective::Operation &operation : perspective->operations()) { - QDockWidget *dock = m_dockForDockId.value(operation.dockId); + for (const Perspective::Operation &op : perspective->m_operations) { + QTC_ASSERT(op.widget, continue); + const QByteArray dockId = op.widget->objectName().toUtf8(); + QDockWidget *dock = m_dockForDockId.value(dockId); if (!dock) { - QTC_CHECK(!operation.widget->objectName().isEmpty()); - dock = registerDockWidget(operation.dockId, operation.widget); + QTC_CHECK(!dockId.isEmpty()); + dock = addDockForWidget(op.widget); + m_dockForDockId[dockId] = dock; QAction *toggleViewAction = dock->toggleViewAction(); 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. dock->setParent(this); - if (operation.operationType == Perspective::Raise) { + if (op.operationType == Perspective::Raise) { dock->raise(); continue; } - addDockWidget(operation.area, dock); - QDockWidget *anchor = m_dockForDockId.value(operation.anchorDockId); - if (!anchor && operation.area == Qt::BottomDockWidgetArea) + addDockWidget(op.area, dock); + QDockWidget *anchor = m_dockForDockId.value(op.anchorDockId); + if (!anchor && op.area == Qt::BottomDockWidgetArea) anchor = m_toolbarDock; if (anchor) { - switch (operation.operationType) { + switch (op.operationType) { case Perspective::AddToTab: tabifyDockWidget(anchor, dock); break; @@ -413,7 +414,7 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId, break; } } - if (!operation.visibleByDefault) + if (!op.visibleByDefault) dock->hide(); else dock->show(); @@ -451,18 +452,8 @@ void DebuggerMainWindow::savePerspectiveHelper(const QByteArray &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() { - foreach (const Operation &operation, m_operations) - delete operation.widget; } void Perspective::setCentralWidget(QWidget *centralWidget) @@ -521,34 +512,22 @@ void ToolbarDescription::addWidget(QWidget *widget) m_widgets.append(widget); } -Perspective::Operation::Operation(const QByteArray &dockId, QWidget *widget, const QByteArray &anchorDockId, - Perspective::OperationType splitType, bool visibleByDefault, - 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) +Perspective::Perspective(const QString &name) + : m_name(name) { - m_docks.append(operation.dockId); - m_operations.append(operation); } -void Perspective::addWindow(QWidget *widget, - Perspective::OperationType op, - bool visibleByDefault, - Qt::DockWidgetArea area) +void Perspective::addWindow(QWidget *widget, OperationType type, QWidget *anchorWidget, + bool visibleByDefault, Qt::DockWidgetArea area) { - const QByteArray dockId = widget->objectName().toUtf8(); - QTC_CHECK(!dockId.isEmpty()); - m_operations.append({dockId, widget, {}, op, visibleByDefault, area}); + Operation op; + op.widget = widget; + if (anchorWidget) + op.anchorDockId = anchorWidget->objectName().toUtf8(); + op.operationType = type; + op.visibleByDefault = visibleByDefault; + op.area = area; + m_operations.append(op); } } // Utils diff --git a/src/plugins/debugger/debuggermainwindow.h b/src/plugins/debugger/debuggermainwindow.h index af2610bd644..d4f45f9dc2d 100644 --- a/src/plugins/debugger/debuggermainwindow.h +++ b/src/plugins/debugger/debuggermainwindow.h @@ -50,39 +50,17 @@ class DEBUGGER_EXPORT Perspective public: 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; - // Takes ownership of all dock widgets in \a operations. - Perspective(const QString &name, - const QVector<Operation> &operations = {}); + explicit Perspective(const QString &name); ~Perspective(); void setCentralWidget(QWidget *centralWidget); - void addOperation(const Operation &operation); void addWindow(QWidget *widget, OperationType op, + QWidget *anchorWidget, bool visibleByDefault = true, 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; } QString name() const; @@ -99,9 +77,20 @@ private: Perspective(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; QByteArray m_parentPerspective; - QVector<QByteArray> m_docks; QVector<Operation> m_operations; QPointer<QWidget> m_centralWidget; Callback m_aboutToActivateCallback; @@ -141,7 +130,6 @@ public: void finalizeSetup(); void showStatusMessage(const QString &message, int timeoutMS); - QDockWidget *dockWidget(const QByteArray &dockId) const; void raiseDock(const QByteArray &dockId); QByteArray currentPerspective() const { return m_currentPerspectiveId; } QStackedWidget *centralWidgetStack() const { return m_centralWidgetStack; } @@ -153,7 +141,6 @@ public: private: void closeEvent(QCloseEvent *) final { savePerspectiveHelper(m_currentPerspectiveId); } - QDockWidget *registerDockWidget(const QByteArray &dockId, QWidget *widget); void loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings = true); void savePerspectiveHelper(const QByteArray &perspectiveId); void increaseChooserWidthIfNecessary(const QString &visibleName); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 1e2c6d02326..8a2eb6032de 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1022,20 +1022,21 @@ public: BaseTreeView *m_stackView = nullptr; BaseTreeView *m_threadsView = nullptr; - QWidget *m_breakWindow = nullptr; BreakHandler *m_breakHandler = nullptr; - QWidget *m_returnWindow = nullptr; - QWidget *m_localsWindow = nullptr; - QWidget *m_watchersWindow = nullptr; - QWidget *m_inspectorWindow = nullptr; - QWidget *m_registerWindow = nullptr; - QWidget *m_modulesWindow = nullptr; - QWidget *m_snapshotWindow = nullptr; - QWidget *m_sourceFilesWindow = nullptr; - QWidget *m_stackWindow = nullptr; - QWidget *m_threadsWindow = nullptr; - LogWindow *m_logWindow = nullptr; - LocalsAndInspectorWindow *m_localsAndInspectorWindow = nullptr; + + QPointer<QWidget> m_returnWindow; + QPointer<QWidget> m_localsWindow; + QPointer<QWidget> m_watchersWindow; + QPointer<QWidget> m_inspectorWindow; + QPointer<LocalsAndInspectorWindow> m_localsAndInspectorWindow; + QPointer<QWidget> m_breakWindow; + QPointer<QWidget> m_registerWindow; + QPointer<QWidget> m_modulesWindow; + QPointer<QWidget> m_snapshotWindow; + QPointer<QWidget> m_sourceFilesWindow; + QPointer<QWidget> m_stackWindow; + QPointer<QWidget> m_threadsWindow; + QPointer<LogWindow> m_logWindow; bool m_busy = false; QString m_lastPermanentStatusMessage; @@ -1088,6 +1089,20 @@ DebuggerPluginPrivate::~DebuggerPluginPrivate() delete m_breakHandler; 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() @@ -1341,8 +1356,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, this, [this](bool on) { m_breakView->setColumnHidden(BreakpointAddressColumn, !on); }); m_breakView->setSettings(settings, "Debugger.BreakWindow"); m_breakView->setModel(m_breakHandler->model()); - m_breakWindow = addSearch(m_breakView, tr("&Breakpoints"), DOCKWIDGET_BREAK); m_breakView->setRootIsDecorated(true); + m_breakWindow = addSearch(m_breakView, tr("&Breakpoints"), DOCKWIDGET_BREAK); m_modulesView = new BaseTreeView; m_modulesView->setSortingEnabled(true); @@ -1486,8 +1501,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, ActionContainer *debugMenu = ActionManager::actionContainer(PE::M_DEBUG); - m_localsAndInspectorWindow = new LocalsAndInspectorWindow( - m_localsWindow, m_inspectorWindow, m_returnWindow); + m_localsAndInspectorWindow = new LocalsAndInspectorWindow + (m_localsWindow, m_inspectorWindow, m_returnWindow); m_localsAndInspectorWindow->setObjectName(DOCKWIDGET_LOCALS_AND_INSPECTOR); m_localsAndInspectorWindow->setWindowTitle(m_localsWindow->windowTitle()); @@ -1830,25 +1845,26 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, // qmlToolbar.addAction(qmlSelectDummyAction, Icons::SELECT_TOOLBAR.icon()); // qmlToolbar.addWidget(new StyledSeparator); - auto createBasePerspective = [this] { return new Perspective({}, { - {DOCKWIDGET_STACK, m_stackWindow, {}, Perspective::SplitVertical}, - {DOCKWIDGET_BREAK, m_breakWindow, DOCKWIDGET_STACK, Perspective::SplitHorizontal}, - {DOCKWIDGET_THREADS, m_threadsWindow, DOCKWIDGET_BREAK, Perspective::AddToTab, false}, - {DOCKWIDGET_MODULES, m_modulesWindow, DOCKWIDGET_THREADS, Perspective::AddToTab, false}, - {DOCKWIDGET_SOURCE_FILES, m_sourceFilesWindow, DOCKWIDGET_MODULES, Perspective::AddToTab, false}, - {DOCKWIDGET_SNAPSHOTS, m_snapshotWindow, DOCKWIDGET_SOURCE_FILES, Perspective::AddToTab, false}, - {DOCKWIDGET_LOCALS_AND_INSPECTOR, m_localsAndInspectorWindow, {}, Perspective::AddToTab, true, - Qt::RightDockWidgetArea}, - {DOCKWIDGET_WATCHERS, m_watchersWindow, DOCKWIDGET_LOCALS_AND_INSPECTOR, Perspective::AddToTab, true, - Qt::RightDockWidgetArea}, - {DOCKWIDGET_OUTPUT, m_logWindow, {}, Perspective::AddToTab, false, Qt::TopDockWidgetArea}, - {DOCKWIDGET_BREAK, nullptr, {}, Perspective::Raise} - }); }; + auto createBasePerspective = [this] { + auto perspective = new Perspective; + perspective->addWindow(m_stackWindow, Perspective::SplitVertical, nullptr); + perspective->addWindow(m_breakWindow, Perspective::SplitHorizontal, m_stackWindow); + perspective->addWindow(m_threadsWindow, Perspective::AddToTab, m_breakWindow, false); + perspective->addWindow(m_modulesWindow, Perspective::AddToTab, m_threadsWindow, false); + perspective->addWindow(m_sourceFilesWindow, Perspective::AddToTab, m_modulesWindow, false); + perspective->addWindow(m_snapshotWindow, Perspective::AddToTab, m_sourceFilesWindow, false); + perspective->addWindow(m_localsAndInspectorWindow, Perspective::AddToTab, nullptr, true, + Qt::RightDockWidgetArea); + perspective->addWindow(m_watchersWindow, Perspective::AddToTab, m_localsAndInspectorWindow, true, + Qt::RightDockWidgetArea); + perspective->addWindow(m_logWindow, Perspective::AddToTab, nullptr, false, Qt::TopDockWidgetArea); + perspective->addWindow(m_breakWindow, Perspective::Raise, nullptr); + return perspective; + }; Perspective *cppPerspective = createBasePerspective(); cppPerspective->setName(tr("Debugger")); - cppPerspective->addOperation({DOCKWIDGET_REGISTER, m_registerWindow, DOCKWIDGET_SNAPSHOTS, - Perspective::AddToTab, false}); + cppPerspective->addWindow(m_registerWindow, Perspective::AddToTab, m_snapshotWindow, false); Debugger::registerToolbar(CppPerspectiveId, toolbar); Debugger::registerPerspective(CppPerspectiveId, cppPerspective); diff --git a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp index a18ffa8a8ec..69b38790462 100644 --- a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp @@ -83,24 +83,28 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent, m_flameGraphView = new FlameGraphView(m_profilerModelManager); prepareEventsView(m_flameGraphView); - QByteArray anchorDockId; + QWidget *anchor = nullptr; if (m_traceView->isUsable()) { - anchorDockId = m_traceView->objectName().toLatin1(); - perspective->addOperation({anchorDockId, m_traceView, {}, Perspective::SplitVertical}); - perspective->addOperation({m_flameGraphView->objectName().toLatin1(), m_flameGraphView, - anchorDockId, Perspective::AddToTab}); + anchor = m_traceView; + perspective->addWindow(m_traceView, Perspective::SplitVertical, nullptr); + perspective->addWindow(m_flameGraphView, Perspective::AddToTab, anchor); } else { - anchorDockId = m_flameGraphView->objectName().toLatin1(); - perspective->addOperation({anchorDockId, m_flameGraphView, {}, - Perspective::SplitVertical}); + anchor = m_flameGraphView; + perspective->addWindow(m_flameGraphView, Perspective::SplitVertical, nullptr); } - perspective->addOperation({m_statisticsView->objectName().toLatin1(), m_statisticsView, - anchorDockId, Perspective::AddToTab}); - perspective->addOperation({anchorDockId, nullptr, {}, Perspective::Raise}); + perspective->addWindow(m_statisticsView, Perspective::AddToTab, anchor); + perspective->addWindow(anchor, Perspective::Raise, nullptr); Debugger::registerPerspective(Constants::QmlProfilerPerspectiveId, perspective); } +QmlProfilerViewManager::~QmlProfilerViewManager() +{ + delete m_traceView; + delete m_flameGraphView; + delete m_statisticsView; +} + void QmlProfilerViewManager::clear() { m_traceView->clear(); diff --git a/src/plugins/qmlprofiler/qmlprofilerviewmanager.h b/src/plugins/qmlprofiler/qmlprofilerviewmanager.h index 655c1933eb2..3fba19d7b1c 100644 --- a/src/plugins/qmlprofiler/qmlprofilerviewmanager.h +++ b/src/plugins/qmlprofiler/qmlprofilerviewmanager.h @@ -44,6 +44,7 @@ public: QmlProfilerViewManager(QObject *parent, QmlProfilerModelManager *modelManager, QmlProfilerStateManager *profilerState); + ~QmlProfilerViewManager(); QmlProfilerTraceView *traceView() const { return m_traceView; } QmlProfilerStatisticsView *statisticsView() const { return m_statisticsView; } diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 240cfce0dc5..f03dab0f4c0 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -105,11 +105,6 @@ namespace Internal { const char CallgrindPerspectiveId[] = "Callgrind.Perspective"; const char CallgrindLocalActionId[] = "Callgrind.Local.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"; class CallgrindTool : public QObject @@ -187,10 +182,10 @@ public: QSortFilterProxyModel m_calleesProxy; // Callgrind widgets - CostView *m_flatView = nullptr; - CostView *m_callersView = nullptr; - CostView *m_calleesView = nullptr; - Visualisation *m_visualization = nullptr; + std::unique_ptr<CostView> m_flatView; + std::unique_ptr<CostView> m_callersView; + std::unique_ptr<CostView> m_calleesView; + std::unique_ptr<Visualisation> m_visualization; // Navigation QAction *m_goBack = nullptr; @@ -312,15 +307,15 @@ CallgrindTool::CallgrindTool() // // DockWidgets // - m_visualization = new Visualisation; + m_visualization = std::make_unique<Visualisation>(); m_visualization->setFrameStyle(QFrame::NoFrame); m_visualization->setObjectName(QLatin1String("Valgrind.CallgrindTool.Visualisation")); m_visualization->setWindowTitle(tr("Visualization")); m_visualization->setModel(&m_dataModel); - connect(m_visualization, &Visualisation::functionActivated, + connect(m_visualization.get(), &Visualisation::functionActivated, this, &CallgrindTool::visualisationFunctionSelected); - m_callersView = new CostView; + m_callersView = std::make_unique<CostView>(); m_callersView->setObjectName(QLatin1String("Valgrind.CallgrindTool.CallersView")); m_callersView->setWindowTitle(tr("Callers")); m_callersView->setSettings(coreSettings, "Valgrind.CallgrindTool.CallersView"); @@ -330,10 +325,10 @@ CallgrindTool::CallgrindTool() m_callersProxy.setSourceModel(&m_callersModel); m_callersView->setModel(&m_callersProxy); m_callersView->hideColumn(CallModel::CalleeColumn); - connect(m_callersView, &QAbstractItemView::activated, + connect(m_callersView.get(), &QAbstractItemView::activated, this, &CallgrindTool::callerFunctionSelected); - m_calleesView = new CostView; + m_calleesView = std::make_unique<CostView>(); m_calleesView->setObjectName(QLatin1String("Valgrind.CallgrindTool.CalleesView")); m_calleesView->setWindowTitle(tr("Callees")); m_calleesView->setSettings(coreSettings, "Valgrind.CallgrindTool.CalleesView"); @@ -343,10 +338,10 @@ CallgrindTool::CallgrindTool() m_calleesProxy.setSourceModel(&m_calleesModel); m_calleesView->setModel(&m_calleesProxy); m_calleesView->hideColumn(CallModel::CallerColumn); - connect(m_calleesView, &QAbstractItemView::activated, + connect(m_calleesView.get(), &QAbstractItemView::activated, this, &CallgrindTool::calleeFunctionSelected); - m_flatView = new CostView; + m_flatView = std::make_unique<CostView>(); m_flatView->setObjectName(QLatin1String("Valgrind.CallgrindTool.FlatView")); m_flatView->setWindowTitle(tr("Functions")); m_flatView->setSettings(coreSettings, "Valgrind.CallgrindTool.FlatView"); @@ -354,7 +349,7 @@ CallgrindTool::CallgrindTool() m_flatView->setFrameStyle(QFrame::NoFrame); m_flatView->setAttribute(Qt::WA_MacShowFocusRect, false); m_flatView->setModel(&m_proxyModel); - connect(m_flatView, &QAbstractItemView::activated, + connect(m_flatView.get(), &QAbstractItemView::activated, this, &CallgrindTool::dataFunctionSelected); updateCostFormat(); @@ -511,13 +506,13 @@ CallgrindTool::CallgrindTool() toolbar.addWidget(m_searchFilter); Debugger::registerToolbar(CallgrindPerspectiveId, toolbar); - Debugger::registerPerspective(CallgrindPerspectiveId, new Perspective(tr("Callgrind"), { - {CallgrindFlatDockId, m_flatView, {}, Perspective::SplitVertical}, - {CallgrindCalleesDockId, m_calleesView, {}, Perspective::SplitVertical}, - {CallgrindCallersDockId, m_callersView, CallgrindCalleesDockId, Perspective::SplitHorizontal}, - {CallgrindVisualizationDockId, m_visualization, {}, Perspective::SplitVertical, - false, Qt::RightDockWidgetArea} - })); + auto perspective = new Perspective(tr("Callgrind")); + perspective->addWindow(m_flatView.get(), Perspective::SplitVertical, nullptr); + perspective->addWindow(m_calleesView.get(), Perspective::SplitVertical, nullptr); + perspective->addWindow(m_callersView.get(), Perspective::SplitHorizontal, m_calleesView.get()); + perspective->addWindow(m_visualization.get(), Perspective::SplitVertical, nullptr, + false, Qt::RightDockWidgetArea); + Debugger::registerPerspective(CallgrindPerspectiveId, perspective); connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions, this, &CallgrindTool::updateRunActions); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 7860156db55..1efd8c3a6f4 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -118,7 +118,6 @@ const char MEMCHECK_RUN_MODE[] = "MemcheckTool.MemcheckRunMode"; const char MEMCHECK_WITH_GDB_RUN_MODE[] = "MemcheckTool.MemcheckWithGdbRunMode"; const char MemcheckPerspectiveId[] = "Memcheck.Perspective"; -const char MemcheckErrorDockId[] = "Memcheck.Dock.Error"; class MemcheckToolRunner : public ValgrindToolRunner @@ -425,7 +424,7 @@ private: Valgrind::XmlProtocol::ErrorListModel m_errorModel; MemcheckErrorFilterProxyModel m_errorProxyModel; - MemcheckErrorView *m_errorView = 0; + std::unique_ptr<MemcheckErrorView> m_errorView; QList<QAction *> m_errorFilterActions; QAction *m_filterProjectAction; @@ -540,7 +539,7 @@ MemcheckTool::MemcheckTool() initKindFilterAction(a, { InvalidFree, MismatchedFree }); m_errorFilterActions.append(a); - m_errorView = new MemcheckErrorView; + m_errorView = std::make_unique<MemcheckErrorView>(); m_errorView->setObjectName(QLatin1String("MemcheckErrorView")); m_errorView->setFrameStyle(QFrame::NoFrame); m_errorView->setAttribute(Qt::WA_MacShowFocusRect, false); @@ -556,9 +555,9 @@ MemcheckTool::MemcheckTool() m_errorView->setObjectName(QLatin1String("Valgrind.MemcheckTool.ErrorView")); m_errorView->setWindowTitle(tr("Memory Issues")); - Debugger::registerPerspective(MemcheckPerspectiveId, new Perspective (tr("Memcheck"), { - {MemcheckErrorDockId, m_errorView, {}, Perspective::SplitVertical} - })); + auto perspective = new Perspective(tr("Memcheck")); + perspective->addWindow(m_errorView.get(), Perspective::SplitVertical, nullptr); + Debugger::registerPerspective(MemcheckPerspectiveId, perspective); connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions, this, &MemcheckTool::maybeActiveRunConfigurationChanged); @@ -583,7 +582,7 @@ MemcheckTool::MemcheckTool() action->setDisabled(true); action->setIcon(Icons::PREV_TOOLBAR.icon()); 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; // Go to next leak. @@ -591,7 +590,7 @@ MemcheckTool::MemcheckTool() action->setDisabled(true); action->setIcon(Icons::NEXT_TOOLBAR.icon()); 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; auto filterButton = new QToolButton; |