aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYasser Grimes <yasser.grimes@qt.io>2023-11-20 15:52:17 +0200
committerYasser Grimes <yasser.grimes@qt.io>2023-11-21 15:15:58 +0000
commitd08bb59faf92d6b869377d16ced4198d7234abe4 (patch)
treebd93a34c90618e67913127f7544733dde2085f23
parent06595222fff5de1900de028e39caaccb9ac943d3 (diff)
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 <alessandro.portale@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r--src/plugins/mcusupport/mcukitmanager.cpp12
-rw-r--r--src/plugins/mcusupport/mcutarget.cpp13
-rw-r--r--src/plugins/mcusupport/mcutarget.h6
3 files changed, 30 insertions, 1 deletions
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 <utils/algorithm.h>
+#include <QCoreApplication>
#include <QMessageBox>
#include <QPushButton>
#include <QRegularExpression>
@@ -430,11 +431,17 @@ bool kitIsUpToDate(const Kit *kit,
QList<Kit *> 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<QString, QStringList> 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<int>(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;