forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
@@ -430,11 +431,17 @@ bool kitIsUpToDate(const Kit *kit,
|
|||||||
QList<Kit *> existingKits(const McuTarget *mcuTarget)
|
QList<Kit *> existingKits(const McuTarget *mcuTarget)
|
||||||
{
|
{
|
||||||
using namespace Constants;
|
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 Utils::filtered(KitManager::kits(), [mcuTarget](Kit *kit) {
|
||||||
return kit->value(KIT_MCUTARGET_KITVERSION_KEY) == KIT_VERSION
|
return kit->value(KIT_MCUTARGET_KITVERSION_KEY) == KIT_VERSION
|
||||||
&& (!mcuTarget
|
&& (!mcuTarget
|
||||||
|| (kit->value(KIT_MCUTARGET_VENDOR_KEY) == mcuTarget->platform().vendor
|
|| (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_COLORDEPTH_KEY) == mcuTarget->colorDepth()
|
||||||
&& kit->value(KIT_MCUTARGET_OS_KEY).toInt()
|
&& kit->value(KIT_MCUTARGET_OS_KEY).toInt()
|
||||||
== static_cast<int>(mcuTarget->os())
|
== static_cast<int>(mcuTarget->os())
|
||||||
@@ -590,6 +597,9 @@ void upgradeKitsByCreatingNewPackage(const SettingsHandler::Ptr &settingsHandler
|
|||||||
if (upgradeOption == UpgradeOption::Replace) {
|
if (upgradeOption == UpgradeOption::Replace) {
|
||||||
for (auto existingKit : kits)
|
for (auto existingKit : kits)
|
||||||
KitManager::deregisterKit(existingKit);
|
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())
|
if (target->isValid())
|
||||||
|
@@ -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
|
QVersionNumber McuTarget::qulVersion() const
|
||||||
{
|
{
|
||||||
return m_qulVersion;
|
return m_qulVersion;
|
||||||
|
@@ -56,6 +56,12 @@ public:
|
|||||||
QString desktopCompilerId() const;
|
QString desktopCompilerId() const;
|
||||||
void handlePackageProblems(MessagesList &messages) 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:
|
private:
|
||||||
const QVersionNumber m_qulVersion;
|
const QVersionNumber m_qulVersion;
|
||||||
const Platform m_platform;
|
const Platform m_platform;
|
||||||
|
Reference in New Issue
Block a user