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