forked from qt-creator/qt-creator
DeviceKitInformation: Warn if something goes wrong
Change-Id: I23bb33a1415dd11e0dafc3d2b7dfa4e391fdcd87 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -74,14 +74,15 @@ bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessa
|
||||
addAutoReleasedObject(new Internal::AndroidDeployConfigurationFactory);
|
||||
addAutoReleasedObject(new Internal::AndroidDeviceFactory);
|
||||
ProjectExplorer::KitManager::instance()->registerKitInformation(new Internal::AndroidGdbServerKitInformation);
|
||||
|
||||
ProjectExplorer::DeviceManager::instance()
|
||||
->addDevice(ProjectExplorer::IDevice::Ptr(new Internal::AndroidDevice));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AndroidPlugin::extensionsInitialized()
|
||||
{
|
||||
ProjectExplorer::DeviceManager *dm = ProjectExplorer::DeviceManager::instance();
|
||||
if (dm->find(Core::Id(Constants::ANDROID_DEVICE_ID)).isNull())
|
||||
dm->addDevice(ProjectExplorer::IDevice::Ptr(new Internal::AndroidDevice));
|
||||
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsChanged()),
|
||||
this, SLOT(kitsRestored()));
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <projectexplorer/abi.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QHBoxLayout>
|
||||
@@ -336,12 +337,8 @@ static const char DEVICE_INFORMATION[] = "PE.Profile.Device";
|
||||
DeviceKitInformation::DeviceKitInformation()
|
||||
{
|
||||
setObjectName(QLatin1String("DeviceInformation"));
|
||||
connect(DeviceManager::instance(), SIGNAL(deviceRemoved(Core::Id)),
|
||||
this, SIGNAL(validationNeeded()));
|
||||
connect(DeviceManager::instance(), SIGNAL(deviceUpdated(Core::Id)),
|
||||
this, SIGNAL(validationNeeded()));
|
||||
connect(DeviceManager::instance(), SIGNAL(deviceUpdated(Core::Id)),
|
||||
this, SLOT(deviceUpdated(Core::Id)));
|
||||
connect(KitManager::instance(), SIGNAL(kitsLoaded()),
|
||||
this, SLOT(kitsWereLoaded()));
|
||||
}
|
||||
|
||||
Core::Id DeviceKitInformation::dataId() const
|
||||
@@ -381,6 +378,16 @@ void DeviceKitInformation::fix(Kit *k)
|
||||
if (!dev.isNull() && dev->type() == DeviceTypeKitInformation::deviceTypeId(k))
|
||||
return;
|
||||
|
||||
setDeviceId(k, Core::Id());
|
||||
}
|
||||
|
||||
void DeviceKitInformation::setup(Kit *k)
|
||||
{
|
||||
QTC_ASSERT(DeviceManager::instance()->isLoaded(), return);
|
||||
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
||||
if (!dev.isNull() && dev->type() == DeviceTypeKitInformation::deviceTypeId(k))
|
||||
return;
|
||||
|
||||
setDeviceId(k, Core::Id::fromSetting(defaultValue(k)));
|
||||
}
|
||||
|
||||
@@ -403,6 +410,7 @@ KitInformation::ItemList DeviceKitInformation::toUserOutput(Kit *k) const
|
||||
|
||||
IDevice::ConstPtr DeviceKitInformation::device(const Kit *k)
|
||||
{
|
||||
QTC_ASSERT(DeviceManager::instance()->isLoaded(), return IDevice::ConstPtr());
|
||||
DeviceManager *dm = DeviceManager::instance();
|
||||
return dm ? dm->find(deviceId(k)) : IDevice::ConstPtr();
|
||||
}
|
||||
@@ -422,11 +430,40 @@ void DeviceKitInformation::setDeviceId(Kit *k, const Core::Id id)
|
||||
k->setValue(DEVICE_INFORMATION, id.toSetting());
|
||||
}
|
||||
|
||||
void DeviceKitInformation::deviceUpdated(const Core::Id &id)
|
||||
void DeviceKitInformation::kitsWereLoaded()
|
||||
{
|
||||
foreach (Kit *k, KitManager::instance()->kits())
|
||||
fix(k);
|
||||
|
||||
connect(DeviceManager::instance(), SIGNAL(deviceAdded(Core::Id)),
|
||||
this, SLOT(deviceAdded(Core::Id)));
|
||||
connect(DeviceManager::instance(), SIGNAL(deviceRemoved(Core::Id)),
|
||||
this, SLOT(deviceRemoved(Core::Id)));
|
||||
connect(DeviceManager::instance(), SIGNAL(deviceUpdated(Core::Id)),
|
||||
this, SLOT(deviceUpdated(Core::Id)));
|
||||
}
|
||||
|
||||
void DeviceKitInformation::deviceUpdated(const Core::Id &id)
|
||||
{
|
||||
foreach (Kit *k, KitManager::instance()->kits()) {
|
||||
if (deviceId(k) == id)
|
||||
notifyAboutUpdate(k);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceKitInformation::deviceAdded(const Core::Id &id)
|
||||
{
|
||||
Q_UNUSED(id);
|
||||
DeviceMatcher m;
|
||||
foreach (Kit *k, KitManager::instance()->kits(&m))
|
||||
fix(k);
|
||||
}
|
||||
|
||||
void DeviceKitInformation::deviceRemoved(const Core::Id &id)
|
||||
{
|
||||
DeviceMatcher m(id);
|
||||
foreach (Kit *k, KitManager::instance()->kits(&m))
|
||||
fix(k);
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
@@ -200,6 +200,7 @@ public:
|
||||
|
||||
QList<Task> validate(const Kit *k) const;
|
||||
void fix(Kit *k);
|
||||
void setup(Kit *k);
|
||||
|
||||
KitConfigWidget *createConfigWidget(Kit *k) const;
|
||||
|
||||
@@ -211,7 +212,11 @@ public:
|
||||
static Core::Id deviceId(const Kit *k);
|
||||
static void setDevice(Kit *k, IDevice::ConstPtr dev);
|
||||
static void setDeviceId(Kit *k, const Core::Id id);
|
||||
|
||||
private slots:
|
||||
void kitsWereLoaded();
|
||||
void deviceAdded(const Core::Id &id);
|
||||
void deviceRemoved(const Core::Id &id);
|
||||
void deviceUpdated(const Core::Id &id);
|
||||
};
|
||||
|
||||
@@ -221,6 +226,8 @@ public:
|
||||
DeviceMatcher(Core::Id id) : m_devId(id)
|
||||
{ }
|
||||
|
||||
DeviceMatcher() { }
|
||||
|
||||
bool matches(const Kit *k) const
|
||||
{
|
||||
return DeviceKitInformation::deviceId(k) == m_devId;
|
||||
|
||||
@@ -346,6 +346,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
d->m_kitManager = new KitManager; // register before ToolChainManager
|
||||
new DeviceManager; // Create DeviceManager singleton
|
||||
d->m_toolChainManager = new ToolChainManager;
|
||||
|
||||
// Register KitInformation:
|
||||
KitManager::instance()->registerKitInformation(new DeviceTypeKitInformation);
|
||||
KitManager::instance()->registerKitInformation(new DeviceKitInformation);
|
||||
KitManager::instance()->registerKitInformation(new SysRootKitInformation);
|
||||
|
||||
addAutoReleasedObject(new Internal::ToolChainOptionsPage);
|
||||
addAutoReleasedObject(new KitOptionsPage);
|
||||
|
||||
@@ -1119,15 +1125,10 @@ void ProjectExplorerPlugin::extensionsInitialized()
|
||||
|
||||
// Register KitInformation:
|
||||
// Only do this now to make sure all device factories were properly initialized.
|
||||
KitManager::instance()->registerKitInformation(new SysRootKitInformation);
|
||||
KitManager::instance()->registerKitInformation(new DeviceKitInformation);
|
||||
KitManager::instance()->registerKitInformation(new DeviceTypeKitInformation);
|
||||
KitManager::instance()->registerKitInformation(new ToolChainKitInformation);
|
||||
|
||||
DeviceManager *dm = DeviceManager::instance();
|
||||
if (dm->find(Core::Id(Constants::DESKTOP_DEVICE_ID)).isNull())
|
||||
DeviceManager::instance()->addDevice(IDevice::Ptr(new DesktopDevice));
|
||||
dm->load();
|
||||
DeviceManager::instance()->load();
|
||||
d->m_toolChainManager->restoreToolChains();
|
||||
d->m_kitManager->restoreKits();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user