forked from qt-creator/qt-creator
RunControl: Reuse portsGatheringRecipe()
Change-Id: I20383f556b3488528758fdf886929afd3ee38a16 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include "customparser.h"
|
||||
#include "devicesupport/devicekitaspects.h"
|
||||
#include "devicesupport/devicemanager.h"
|
||||
#include "devicesupport/deviceusedportsgatherer.h"
|
||||
#include "devicesupport/idevice.h"
|
||||
#include "devicesupport/idevicefactory.h"
|
||||
#include "devicesupport/sshparameters.h"
|
||||
@@ -357,14 +356,14 @@ public:
|
||||
void startTaskTree();
|
||||
void checkAutoDeleteAndEmitStopped();
|
||||
|
||||
void enablePortsGatherer();
|
||||
bool isPortsGatherer() const
|
||||
{ return useDebugChannel || useQmlChannel || usePerfChannel || useWorkerChannel; }
|
||||
QUrl getNextChannel(PortList *portList, const QList<Port> &usedPorts);
|
||||
|
||||
RunControl *q;
|
||||
Id runMode;
|
||||
TaskTreeRunner m_taskTreeRunner;
|
||||
|
||||
std::unique_ptr<DeviceUsedPortsGatherer> portsGatherer;
|
||||
TaskTreeRunner m_portsGathererRunner;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
@@ -592,15 +591,21 @@ void RunControlPrivate::initiateReStart()
|
||||
|
||||
void RunControlPrivate::startPortsGathererIfNeededAndContinueStart()
|
||||
{
|
||||
if (!portsGatherer) {
|
||||
if (!isPortsGatherer()) {
|
||||
continueStart();
|
||||
return;
|
||||
}
|
||||
|
||||
connect(portsGatherer.get(), &DeviceUsedPortsGatherer::done, this, [this](bool success) {
|
||||
if (success) {
|
||||
const Storage<PortsOutputData> portsStorage;
|
||||
|
||||
const auto onDone = [this, portsStorage] {
|
||||
const auto ports = *portsStorage;
|
||||
if (!ports) {
|
||||
onWorkerFailed(nullptr, ports.error());
|
||||
return;
|
||||
}
|
||||
PortList portList = device->freePorts();
|
||||
const QList<Port> usedPorts = portsGatherer->usedPorts();
|
||||
const QList<Port> usedPorts = *ports;
|
||||
q->appendMessage(Tr::tr("Found %n free ports.", nullptr, portList.count()) + '\n',
|
||||
NormalMessageFormat);
|
||||
if (useDebugChannel)
|
||||
@@ -613,20 +618,16 @@ void RunControlPrivate::startPortsGathererIfNeededAndContinueStart()
|
||||
workerChannel = getNextChannel(&portList, usedPorts);
|
||||
|
||||
continueStart();
|
||||
} else {
|
||||
onWorkerFailed(nullptr, portsGatherer->errorString());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const Group recipe {
|
||||
portsStorage,
|
||||
device->portsGatheringRecipe(portsStorage),
|
||||
onGroupDone(onDone)
|
||||
};
|
||||
|
||||
q->appendMessage(Tr::tr("Checking available ports...") + '\n', NormalMessageFormat);
|
||||
portsGatherer->setDevice(device);
|
||||
portsGatherer->start();
|
||||
}
|
||||
|
||||
void RunControlPrivate::enablePortsGatherer()
|
||||
{
|
||||
if (!portsGatherer)
|
||||
portsGatherer = std::make_unique<DeviceUsedPortsGatherer>();
|
||||
m_portsGathererRunner.start(recipe);
|
||||
}
|
||||
|
||||
QUrl RunControlPrivate::getNextChannel(PortList *portList, const QList<Port> &usedPorts)
|
||||
@@ -643,7 +644,6 @@ QUrl RunControlPrivate::getNextChannel(PortList *portList, const QList<Port> &us
|
||||
|
||||
void RunControl::requestDebugChannel()
|
||||
{
|
||||
d->enablePortsGatherer();
|
||||
d->useDebugChannel = true;
|
||||
}
|
||||
|
||||
@@ -659,7 +659,6 @@ QUrl RunControl::debugChannel() const
|
||||
|
||||
void RunControl::requestQmlChannel()
|
||||
{
|
||||
d->enablePortsGatherer();
|
||||
d->useQmlChannel = true;
|
||||
}
|
||||
|
||||
@@ -680,7 +679,6 @@ void RunControl::setQmlChannel(const QUrl &channel)
|
||||
|
||||
void RunControl::requestPerfChannel()
|
||||
{
|
||||
d->enablePortsGatherer();
|
||||
d->usePerfChannel = true;
|
||||
}
|
||||
|
||||
@@ -696,7 +694,6 @@ QUrl RunControl::perfChannel() const
|
||||
|
||||
void RunControl::requestWorkerChannel()
|
||||
{
|
||||
d->enablePortsGatherer();
|
||||
d->useWorkerChannel = true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user