From d08bb59faf92d6b869377d16ced4198d7234abe4 Mon Sep 17 00:00:00 2001 From: Yasser Grimes Date: Mon, 20 Nov 2023 15:52:17 +0200 Subject: McuSupport: Reset invalid packages to default on update When updating kits some packages will still have the cached value of the outdated package resulting in failure on updated. although default paths would have given the correct path. This patch restore package values to the default value, in addition to tracking changes in model-names that correspond to the same kit. Fixes: QTCREATORBUG-29855 Change-Id: Iad52df93e1e39c7f56bdb30036ac21cda8cdf670 Reviewed-by: Alessandro Portale Reviewed-by: Eike Ziller --- src/plugins/mcusupport/mcukitmanager.cpp | 12 +++++++++++- src/plugins/mcusupport/mcutarget.cpp | 13 +++++++++++++ src/plugins/mcusupport/mcutarget.h | 6 ++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/plugins/mcusupport/mcukitmanager.cpp b/src/plugins/mcusupport/mcukitmanager.cpp index 39e13f8089..2cc2311e69 100644 --- a/src/plugins/mcusupport/mcukitmanager.cpp +++ b/src/plugins/mcusupport/mcukitmanager.cpp @@ -30,6 +30,7 @@ #include +#include #include #include #include @@ -430,11 +431,17 @@ bool kitIsUpToDate(const Kit *kit, QList existingKits(const McuTarget *mcuTarget) { using namespace Constants; + // some models have compatible name changes that refere to the same supported board across versions. + // name changes are tracked here to recognize the corresponding kits as upgradable. + static QMap upgradable_to = { + {"MIMXRT1170-EVK-FREERTOS", {"MIMXRT1170-EVKB-FREERTOS"}}}; return Utils::filtered(KitManager::kits(), [mcuTarget](Kit *kit) { return kit->value(KIT_MCUTARGET_KITVERSION_KEY) == KIT_VERSION && (!mcuTarget || (kit->value(KIT_MCUTARGET_VENDOR_KEY) == mcuTarget->platform().vendor - && kit->value(KIT_MCUTARGET_MODEL_KEY) == mcuTarget->platform().name + && (kit->value(KIT_MCUTARGET_MODEL_KEY) == mcuTarget->platform().name + || upgradable_to[kit->value(KIT_MCUTARGET_MODEL_KEY).toString()].contains( + mcuTarget->platform().name)) && kit->value(KIT_MCUTARGET_COLORDEPTH_KEY) == mcuTarget->colorDepth() && kit->value(KIT_MCUTARGET_OS_KEY).toInt() == static_cast(mcuTarget->os()) @@ -590,6 +597,9 @@ void upgradeKitsByCreatingNewPackage(const SettingsHandler::Ptr &settingsHandler if (upgradeOption == UpgradeOption::Replace) { for (auto existingKit : kits) KitManager::deregisterKit(existingKit); + // Reset cached values that are not valid after an update + // Exp: a board sdk version that was dropped in newer releases + target->resetInvalidPathsToDefault(); } if (target->isValid()) diff --git a/src/plugins/mcusupport/mcutarget.cpp b/src/plugins/mcusupport/mcutarget.cpp index d7a3b0fe39..faef32b61b 100644 --- a/src/plugins/mcusupport/mcutarget.cpp +++ b/src/plugins/mcusupport/mcutarget.cpp @@ -113,6 +113,19 @@ void McuTarget::handlePackageProblems(MessagesList &messages) const } } +void McuTarget::resetInvalidPathsToDefault() +{ + + for (McuPackagePtr package : std::as_const(m_packages)) { + if (!package) + continue; + if (package->isValidStatus()) + continue; + package->setPath(package->defaultPath()); + package->writeToSettings(); + } +} + QVersionNumber McuTarget::qulVersion() const { return m_qulVersion; diff --git a/src/plugins/mcusupport/mcutarget.h b/src/plugins/mcusupport/mcutarget.h index 8ee19f54ab..ce715c8c6f 100644 --- a/src/plugins/mcusupport/mcutarget.h +++ b/src/plugins/mcusupport/mcutarget.h @@ -56,6 +56,12 @@ public: QString desktopCompilerId() const; void handlePackageProblems(MessagesList &messages) const; + // Used when updating to new version of QtMCUs + // Paths that is not valid in the new version, + // and were valid in the old version. have the possibility be valid if + // reset to the default value without user intervention + void resetInvalidPathsToDefault(); + private: const QVersionNumber m_qulVersion; const Platform m_platform; -- cgit v1.2.3