forked from qt-creator/qt-creator
Docker: De-register some auto-detected items on device removal
Kit and QtVersion for now, ToolChains seem to lack easy access. Change-Id: I657cb075dd3b4f6fd8ebfd3d6d20b1cdd4dce831 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/devicesupport/idevicewidget.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
@@ -139,6 +140,22 @@ void DockerDeviceProcess::start(const Runnable &runnable)
|
||||
dockerDevice->runProcess(m_process);
|
||||
}
|
||||
|
||||
void DockerDevice::aboutToBeRemoved() const
|
||||
{
|
||||
for (Kit *kit : KitManager::kits()) {
|
||||
if (kit->autoDetectionSource() == id().toString())
|
||||
KitManager::deregisterKit(kit);
|
||||
};
|
||||
for (BaseQtVersion *qtVersion : QtVersionManager::versions()) {
|
||||
if (qtVersion->autodetectionSource() == id().toString())
|
||||
QtVersionManager::removeVersion(qtVersion);
|
||||
};
|
||||
// for (ToolChain *toolChain : ToolChainManager::toolChains()) {
|
||||
// if (toolChain->autoDetectionSource() == id.toString())
|
||||
// // FIXME: Implement
|
||||
// };
|
||||
}
|
||||
|
||||
void DockerDeviceProcess::interrupt()
|
||||
{
|
||||
device()->signalOperation()->interruptProcess(m_process.processId());
|
||||
@@ -363,11 +380,10 @@ const DockerDeviceData &DockerDevice::data() const
|
||||
BaseQtVersion *DockerDevicePrivate::autoDetectQtVersion() const
|
||||
{
|
||||
QString error;
|
||||
QString source = "docker:" + m_data.imageId;
|
||||
const QStringList candidates = {"/usr/local/bin/qmake", "/usr/bin/qmake"};
|
||||
for (const QString &candidate : candidates) {
|
||||
const FilePath qmake = q->mapToGlobalPath(FilePath::fromString(candidate));
|
||||
if (auto qtVersion = QtVersionFactory::createQtVersionFromQMakePath(qmake, false, source, &error)) {
|
||||
if (auto qtVersion = QtVersionFactory::createQtVersionFromQMakePath(qmake, false, m_data.id(), &error)) {
|
||||
QtVersionManager::addVersion(qtVersion);
|
||||
return qtVersion;
|
||||
}
|
||||
@@ -399,7 +415,6 @@ void DockerDevicePrivate::autoDetectCMake()
|
||||
return;
|
||||
|
||||
QString error;
|
||||
QString source = "docker:" + m_data.imageId;
|
||||
const QStringList candidates = {"/usr/local/bin/cmake", "/usr/bin/cmake"};
|
||||
for (const QString &candidate : candidates) {
|
||||
const FilePath cmake = q->mapToGlobalPath(FilePath::fromString(candidate));
|
||||
@@ -425,7 +440,7 @@ void DockerDevicePrivate::setupKit()
|
||||
|
||||
const auto initializeKit = [this, toolChains, qt](Kit *k) {
|
||||
k->setAutoDetected(false);
|
||||
k->setAutoDetectionSource("DockerDevice:" + m_data.imageId);
|
||||
k->setAutoDetectionSource(m_data.id());
|
||||
k->setUnexpandedDisplayName("%{Device:Name}");
|
||||
|
||||
DeviceTypeKitAspect::setDeviceTypeId(k, Constants::DOCKER_DEVICE_TYPE);
|
||||
|
@@ -38,6 +38,8 @@ namespace Internal {
|
||||
class DockerDeviceData
|
||||
{
|
||||
public:
|
||||
QString id() const { return "docker:" + imageId; }
|
||||
|
||||
QString imageId;
|
||||
QString repo;
|
||||
QString tag;
|
||||
@@ -100,6 +102,8 @@ private:
|
||||
void fromMap(const QVariantMap &map) final;
|
||||
QVariantMap toMap() const final;
|
||||
|
||||
void aboutToBeRemoved() const final;
|
||||
|
||||
class DockerDevicePrivate *d = nullptr;
|
||||
friend class DockerDeviceSetupWizard;
|
||||
};
|
||||
|
@@ -97,7 +97,16 @@ int DeviceManager::deviceCount() const
|
||||
|
||||
void DeviceManager::replaceInstance()
|
||||
{
|
||||
const QList<Id> newIds =
|
||||
Utils::transform(DeviceManagerPrivate::clonedInstance->d->devices, &IDevice::id);
|
||||
|
||||
for (IDevice::Ptr dev : m_instance->d->devices) {
|
||||
if (!newIds.contains(dev->id()))
|
||||
dev->aboutToBeRemoved();
|
||||
}
|
||||
|
||||
copy(DeviceManagerPrivate::clonedInstance, instance(), false);
|
||||
|
||||
emit instance()->deviceListReplaced();
|
||||
emit instance()->updated();
|
||||
}
|
||||
|
@@ -250,6 +250,8 @@ public:
|
||||
virtual void runProcess(Utils::QtcProcess &process) const;
|
||||
virtual Utils::Environment systemEnvironment() const;
|
||||
|
||||
virtual void aboutToBeRemoved() const {}
|
||||
|
||||
protected:
|
||||
IDevice();
|
||||
|
||||
|
Reference in New Issue
Block a user