aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/valgrind/memchecktool.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2017-05-09 10:25:11 +0200
committerhjk <hjk@qt.io>2017-05-15 14:35:03 +0000
commit89f02cba2ca65f84d99b0b35f555da024f3e2234 (patch)
tree408bd4b2da13e00227697f871cefbf1ea9c4ab98 /src/plugins/valgrind/memchecktool.cpp
parent9b93d5a330a4898d12ce99414a51d1bd6cda51ec (diff)
ProjectExplorer: Split Target and ToolRunners into smaller tasks
This increases re-usability of activities like 'port gathering', and makes their use less dependent on actual device implementations. Change-Id: I017cb74874f2b38c487ba2d03906a675d5618647 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/valgrind/memchecktool.cpp')
-rw-r--r--src/plugins/valgrind/memchecktool.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp
index 4c8d421a6c..f452a845df 100644
--- a/src/plugins/valgrind/memchecktool.cpp
+++ b/src/plugins/valgrind/memchecktool.cpp
@@ -244,7 +244,7 @@ class MemcheckTool : public QObject
public:
MemcheckTool(QObject *parent);
- RunControl *createRunControl(RunConfiguration *runConfiguration, Core::Id runMode);
+ RunWorker *createRunWorker(RunControl *runControl);
private:
void updateRunActions();
@@ -395,8 +395,10 @@ MemcheckTool::MemcheckTool(QObject *parent)
ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER);
QString toolTip = tr("Valgrind Analyze Memory uses the Memcheck tool to find memory leaks.");
+ RunControl::registerWorkerCreator(MEMCHECK_RUN_MODE, std::bind(&MemcheckTool::createRunWorker, this, _1));
+ RunControl::registerWorkerCreator(MEMCHECK_WITH_GDB_RUN_MODE, std::bind(&MemcheckTool::createRunWorker, this, _1));
+
if (!Utils::HostOsInfo::isWindowsHost()) {
- Debugger::registerAction(MEMCHECK_RUN_MODE, std::bind(&MemcheckTool::createRunControl, this, _1, _2));
action = new QAction(this);
action->setText(tr("Valgrind Memory Analyzer"));
action->setToolTip(toolTip);
@@ -414,7 +416,6 @@ MemcheckTool::MemcheckTool(QObject *parent)
action->setEnabled(m_startAction->isEnabled());
});
- Debugger::registerAction(MEMCHECK_WITH_GDB_RUN_MODE, std::bind(&MemcheckTool::createRunControl, this, _1, _2));
action = new QAction(this);
action->setText(tr("Valgrind Memory Analyzer with GDB"));
action->setToolTip(tr("Valgrind Analyze Memory with GDB uses the "
@@ -435,7 +436,6 @@ MemcheckTool::MemcheckTool(QObject *parent)
});
}
- Debugger::registerAction(MEMCHECK_RUN_MODE, std::bind(&MemcheckTool::createRunControl, this, _1, _2));
action = new QAction(this);
action->setText(tr("Valgrind Memory Analyzer (External Application)"));
action->setToolTip(toolTip);
@@ -452,8 +452,8 @@ MemcheckTool::MemcheckTool(QObject *parent)
return;
TaskHub::clearTasks(Debugger::Constants::ANALYZERTASK_ID);
Debugger::selectPerspective(MemcheckPerspectiveId);
- RunControl *rc = createRunControl(runConfig, MEMCHECK_RUN_MODE);
- QTC_ASSERT(rc, return);
+ RunControl *rc = new RunControl(runConfig, MEMCHECK_RUN_MODE);
+ rc->createWorker(MEMCHECK_RUN_MODE);
const auto runnable = dlg.runnable();
rc->setRunnable(runnable);
AnalyzerConnection connection;
@@ -560,14 +560,14 @@ void MemcheckTool::maybeActiveRunConfigurationChanged()
updateFromSettings();
}
-RunControl *MemcheckTool::createRunControl(RunConfiguration *runConfiguration, Core::Id runMode)
+RunWorker *MemcheckTool::createRunWorker(RunControl *runControl)
{
- m_errorModel.setRelevantFrameFinder(makeFrameFinder(runConfiguration
- ? runConfiguration->target()->project()->files(Project::AllFiles) : QStringList()));
+ RunConfiguration *runConfig = runControl->runConfiguration();
+ m_errorModel.setRelevantFrameFinder(makeFrameFinder(runConfig
+ ? runConfig->target()->project()->files(Project::AllFiles) : QStringList()));
- auto runControl = new RunControl(runConfiguration, runMode);
MemcheckToolRunner *runTool = 0;
- if (runMode == MEMCHECK_RUN_MODE)
+ if (runControl->runMode() == MEMCHECK_RUN_MODE)
runTool = new MemcheckToolRunner(runControl);
else
runTool = new MemcheckWithGdbToolRunner(runControl);
@@ -583,7 +583,7 @@ RunControl *MemcheckTool::createRunControl(RunConfiguration *runConfiguration, C
m_toolBusy = true;
updateRunActions();
- return runControl;
+ return runTool;
}
void MemcheckTool::engineStarting(const MemcheckToolRunner *runTool)
@@ -739,7 +739,9 @@ public:
RunControl *create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) override
{
Q_UNUSED(errorMessage);
- return m_tool->createRunControl(runConfiguration, mode);
+ auto runControl = new RunControl(runConfiguration, mode);
+ runControl->createWorker(mode);
+ return runControl;
}
// Do not create an aspect, let the Callgrind tool create one and use that, too.