forked from qt-creator/qt-creator
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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user