forked from qt-creator/qt-creator
DeviceCheckBuildStep: Employ task tree for running
Task-number: QTCREATORBUG-29168 Change-Id: I3506663263d8ebdc922bd6ac1b11357f4a6dba8f Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -8,9 +8,10 @@
|
|||||||
#include "../projectexplorertr.h"
|
#include "../projectexplorertr.h"
|
||||||
|
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "idevice.h"
|
|
||||||
#include "idevicefactory.h"
|
#include "idevicefactory.h"
|
||||||
|
|
||||||
|
#include <solutions/tasking/tasktree.h>
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -26,12 +27,17 @@ public:
|
|||||||
|
|
||||||
bool init() override
|
bool init() override
|
||||||
{
|
{
|
||||||
|
if (!BuildStep::init())
|
||||||
|
return false;
|
||||||
|
|
||||||
IDevice::ConstPtr device = DeviceKitAspect::device(kit());
|
IDevice::ConstPtr device = DeviceKitAspect::device(kit());
|
||||||
if (!device) {
|
if (device)
|
||||||
|
return true;
|
||||||
|
|
||||||
Utils::Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(kit());
|
Utils::Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(kit());
|
||||||
IDeviceFactory *factory = IDeviceFactory::find(deviceTypeId);
|
IDeviceFactory *factory = IDeviceFactory::find(deviceTypeId);
|
||||||
if (!factory || !factory->canCreate()) {
|
if (!factory || !factory->canCreate()) {
|
||||||
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
|
emit addOutput(Tr::tr("No device configured."), OutputFormat::ErrorMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,26 +46,24 @@ public:
|
|||||||
QMessageBox::Yes | QMessageBox::No);
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||||
if (msgBox.exec() == QMessageBox::No) {
|
if (msgBox.exec() == QMessageBox::No) {
|
||||||
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
|
emit addOutput(Tr::tr("No device configured."), OutputFormat::ErrorMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDevice::Ptr newDevice = factory->create();
|
IDevice::Ptr newDevice = factory->create();
|
||||||
if (newDevice.isNull()) {
|
if (newDevice.isNull()) {
|
||||||
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
|
emit addOutput(Tr::tr("No device configured."), OutputFormat::ErrorMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceManager *dm = DeviceManager::instance();
|
DeviceManager *dm = DeviceManager::instance();
|
||||||
dm->addDevice(newDevice);
|
dm->addDevice(newDevice);
|
||||||
|
|
||||||
DeviceKitAspect::setDevice(kit(), newDevice);
|
DeviceKitAspect::setDevice(kit(), newDevice);
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doRun() override { emit finished(true); }
|
private:
|
||||||
|
Tasking::GroupItem runRecipe() final { return Tasking::Group{}; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Factory
|
// Factory
|
||||||
|
Reference in New Issue
Block a user