aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/valgrind/callgrindtool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/valgrind/callgrindtool.cpp')
-rw-r--r--src/plugins/valgrind/callgrindtool.cpp93
1 files changed, 46 insertions, 47 deletions
diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp
index 2903b3cae56..faa08371e73 100644
--- a/src/plugins/valgrind/callgrindtool.cpp
+++ b/src/plugins/valgrind/callgrindtool.cpp
@@ -98,7 +98,6 @@ using namespace Valgrind::Callgrind;
using namespace TextEditor;
using namespace ProjectExplorer;
using namespace Utils;
-using namespace std::placeholders;
namespace Valgrind {
namespace Internal {
@@ -106,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
@@ -121,7 +115,7 @@ public:
CallgrindTool();
~CallgrindTool();
- ValgrindToolRunner *createRunTool(RunControl *runControl);
+ void setupRunner(CallgrindToolRunner *runner);
void setParseData(ParseData *data);
CostDelegate::CostFormat costFormat() const;
@@ -188,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;
+ QPointer<CostView> m_flatView;
+ QPointer<CostView> m_callersView;
+ QPointer<CostView> m_calleesView;
+ QPointer<Visualization> m_visualization;
// Navigation
QAction *m_goBack = nullptr;
@@ -272,7 +266,7 @@ CallgrindTool::CallgrindTool()
action->setToolTip(toolTip);
menu->addAction(ActionManager::registerAction(action, CallgrindRemoteActionId),
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
- QObject::connect(action, &QAction::triggered, this, [this, action] {
+ QObject::connect(action, &QAction::triggered, this, [action] {
auto runConfig = RunConfiguration::startupRunConfiguration();
if (!runConfig) {
showCannotStartDialog(action->text());
@@ -283,10 +277,11 @@ CallgrindTool::CallgrindTool()
return;
Debugger::selectPerspective(CallgrindPerspectiveId);
auto runControl = new RunControl(runConfig, CALLGRIND_RUN_MODE);
+ if (auto creator = RunControl::producer(runConfig, CALLGRIND_RUN_MODE))
+ creator(runControl);
const auto runnable = dlg.runnable();
runControl->setRunnable(runnable);
runControl->setDisplayName(runnable.executable);
- createRunTool(runControl);
ProjectExplorerPlugin::startRunControl(runControl);
});
@@ -312,12 +307,12 @@ CallgrindTool::CallgrindTool()
//
// DockWidgets
//
- m_visualization = new Visualisation;
+ m_visualization = new Visualization;
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, &Visualization::functionActivated,
this, &CallgrindTool::visualisationFunctionSelected);
m_callersView = new CostView;
@@ -424,18 +419,18 @@ CallgrindTool::CallgrindTool()
this, &CallgrindTool::setCostEvent);
updateEventCombo();
- ToolbarDescription toolbar;
- toolbar.addAction(m_startAction);
- toolbar.addAction(m_stopAction);
- toolbar.addAction(m_loadExternalLogFile);
- toolbar.addAction(m_dumpAction);
- toolbar.addAction(m_resetAction);
- toolbar.addAction(m_pauseAction);
- toolbar.addAction(m_discardAction);
- toolbar.addAction(m_goBack);
- toolbar.addAction(m_goNext);
- toolbar.addWidget(new Utils::StyledSeparator);
- toolbar.addWidget(m_eventCombo);
+ auto perspective = new Perspective(CallgrindPerspectiveId, tr("Callgrind"));
+ perspective->addToolbarAction(m_startAction);
+ perspective->addToolbarAction(m_stopAction);
+ perspective->addToolbarAction(m_loadExternalLogFile);
+ perspective->addToolbarAction(m_dumpAction);
+ perspective->addToolbarAction(m_resetAction);
+ perspective->addToolbarAction(m_pauseAction);
+ perspective->addToolbarAction(m_discardAction);
+ perspective->addToolbarAction(m_goBack);
+ perspective->addToolbarAction(m_goNext);
+ perspective->addToolbarSeparator();
+ perspective->addToolbarWidget(m_eventCombo);
// Cost formatting
{
@@ -468,7 +463,7 @@ CallgrindTool::CallgrindTool()
button->setPopupMode(QToolButton::InstantPopup);
button->setText(QLatin1String("$"));
button->setToolTip(tr("Cost Format"));
- toolbar.addWidget(button);
+ perspective->addToolbarWidget(button);
}
ValgrindGlobalSettings *settings = ValgrindPlugin::globalSettings();
@@ -505,19 +500,17 @@ CallgrindTool::CallgrindTool()
setCostFormat(settings->costFormat());
enableCycleDetection(settings->detectCycles());
- toolbar.addAction(m_cycleDetection);
- toolbar.addAction(m_shortenTemplates);
- toolbar.addAction(m_filterProjectCosts);
- toolbar.addWidget(m_searchFilter);
- Debugger::registerToolbar(CallgrindPerspectiveId, toolbar);
+ perspective->addToolbarAction(m_cycleDetection);
+ perspective->addToolbarAction(m_shortenTemplates);
+ perspective->addToolbarAction(m_filterProjectCosts);
+ perspective->addToolbarWidget(m_searchFilter);
- 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}
- }));
+ perspective->addWindow(m_flatView, Perspective::SplitVertical, nullptr);
+ perspective->addWindow(m_calleesView, Perspective::SplitVertical, nullptr);
+ perspective->addWindow(m_callersView, Perspective::SplitHorizontal, m_calleesView);
+ perspective->addWindow(m_visualization, Perspective::SplitVertical, nullptr,
+ false, Qt::RightDockWidgetArea);
+ Debugger::registerPerspective(perspective);
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
this, &CallgrindTool::updateRunActions);
@@ -526,6 +519,10 @@ CallgrindTool::CallgrindTool()
CallgrindTool::~CallgrindTool()
{
qDeleteAll(m_textMarks);
+ delete m_flatView;
+ delete m_callersView;
+ delete m_calleesView;
+ delete m_visualization;
}
void CallgrindTool::doClear(bool clearParseData)
@@ -747,9 +744,9 @@ void CallgrindTool::updateEventCombo()
m_eventCombo->addItem(ParseData::prettyStringForEvent(event));
}
-ValgrindToolRunner *CallgrindTool::createRunTool(RunControl *runControl)
+void CallgrindTool::setupRunner(CallgrindToolRunner *toolRunner)
{
- auto toolRunner = new CallgrindToolRunner(runControl);
+ RunControl *runControl = toolRunner->runControl();
connect(toolRunner, &CallgrindToolRunner::parserDataReady, this, &CallgrindTool::takeParserDataFromRunControl);
connect(runControl, &RunControl::stopped, this, &CallgrindTool::engineFinished);
@@ -767,7 +764,7 @@ ValgrindToolRunner *CallgrindTool::createRunTool(RunControl *runControl)
toolRunner->setToggleCollectFunction(m_toggleCollectFunction);
m_toggleCollectFunction.clear();
- QTC_ASSERT(m_visualization, return toolRunner);
+ QTC_ASSERT(m_visualization, return);
// apply project settings
if (IRunConfigurationAspect *analyzerAspect = runControl->runConfiguration()->extraAspect(ANALYZER_VALGRIND_SETTINGS)) {
@@ -787,8 +784,6 @@ ValgrindToolRunner *CallgrindTool::createRunTool(RunControl *runControl)
m_loadExternalLogFile->setEnabled(false);
clearTextMarks();
doClear(true);
-
- return toolRunner;
}
void CallgrindTool::updateRunActions()
@@ -974,12 +969,16 @@ void CallgrindTool::createTextMarks()
static CallgrindTool *theCallgrindTool;
+void setupCallgrindRunner(CallgrindToolRunner *toolRunner)
+{
+ theCallgrindTool->setupRunner(toolRunner);
+}
+
void initCallgrindTool()
{
theCallgrindTool = new CallgrindTool;
- auto producer = std::bind(&CallgrindTool::createRunTool, theCallgrindTool, _1);
- RunControl::registerWorker(CALLGRIND_RUN_MODE, producer);
+ RunControl::registerWorker<CallgrindToolRunner>(CALLGRIND_RUN_MODE, {});
}
void destroyCallgrindTool()