ProjectExplorer: Use std::function for SimpleTargetRunner::start()

This spares us the typical r = runnable(); modify(r); setRunnable(r)
roundtrip and the m_runnable storage that might or might not
be the same as runControl->runnable. Similar for m_device.

Change-Id: I8300260dd8dd7cd395e40bcd3d2ae45089085008
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2019-09-02 18:22:35 +02:00
parent 8d85a7c2bc
commit 4028a41d2e
17 changed files with 222 additions and 290 deletions

View File

@@ -91,23 +91,18 @@ public:
EmrunRunWorker(RunControl *runControl)
: SimpleTargetRunner(runControl)
{
m_portsGatherer = new PortsGatherer(runControl);
addStartDependency(m_portsGatherer);
auto portsGatherer = new PortsGatherer(runControl);
addStartDependency(portsGatherer);
setStarter([this, runControl, portsGatherer] {
CommandLine cmd = emrunCommand(runControl->target(),
runControl->aspect<WebBrowserSelectionAspect>()->currentBrowser(),
QString::number(portsGatherer->findEndPoint().port()));
Runnable r;
r.setCommandLine(cmd);
SimpleTargetRunner::doStart(r, {});
});
}
void start() final
{
CommandLine cmd = emrunCommand(runControl()->target(),
runControl()->aspect<WebBrowserSelectionAspect>()->currentBrowser(),
QString::number(m_portsGatherer->findEndPoint().port()));
Runnable r;
r.setCommandLine(cmd);
setRunnable(r);
SimpleTargetRunner::start();
}
PortsGatherer *m_portsGatherer;
};
RunWorkerFactory::WorkerCreator makeEmrunWorker()