McuSupport: Remove outdated Qt for MCUs kits

Add a version to the generated Qt for MCUs kits. That version will
increase with every change to the way Qt for MCUs kits get generated.

If there are auto-detected Qt for MCUs kits with a different version
than the current, remove these kits when a "fresh" gets generated.

Task-number: QTCREATORBUG-23891
Change-Id: Iafcd2342d458f9c77ada47180cb61b3b4b090598
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Alessandro Portale
2020-04-22 23:24:54 +02:00
parent ab840d0043
commit 5795ce2aae
4 changed files with 22 additions and 0 deletions

View File

@@ -61,6 +61,8 @@
namespace McuSupport {
namespace Internal {
static const int KIT_VERSION = 1; // Bumps up whenever details in Kit creation change
static QString packagePathFromSettings(const QString &settingsKey, const QString &defaultPath = {})
{
QSettings *s = Core::ICore::settings();
@@ -473,6 +475,7 @@ static void setKitProperties(const QString &kitName, ProjectExplorer::Kit *k,
k->setValue(Constants::KIT_MCUTARGET_MODEL_KEY, mcuTarget->qulPlatform());
k->setValue(Constants::KIT_MCUTARGET_SDKVERSION_KEY,
McuSupportOptions::supportedQulVersion().toString());
k->setValue(Constants::KIT_MCUTARGET_KITVERSION_KEY, KIT_VERSION);
k->setAutoDetected(true);
k->makeSticky();
if (mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop)
@@ -613,6 +616,21 @@ QList<ProjectExplorer::Kit *> McuSupportOptions::existingKits(const McuTarget *m
});
}
QList<ProjectExplorer::Kit *> McuSupportOptions::outdatedKits()
{
return Utils::filtered(ProjectExplorer::KitManager::kits(), [](ProjectExplorer::Kit *kit) {
return kit->isAutoDetected()
&& !kit->value(Constants::KIT_MCUTARGET_VENDOR_KEY).isNull()
&& kit->value(Constants::KIT_MCUTARGET_KITVERSION_KEY) != KIT_VERSION;
});
}
void McuSupportOptions::removeOutdatedKits()
{
for (auto kit : McuSupportOptions::outdatedKits())
ProjectExplorer::KitManager::deregisterKit(kit);
}
ProjectExplorer::Kit *McuSupportOptions::newKit(const McuTarget *mcuTarget)
{
using namespace ProjectExplorer;