summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2020-06-05 07:41:08 +0300
committerKatja Marttila <katja.marttila@qt.io>2020-06-08 10:01:48 +0300
commitffccc5a021632ba6989575da46a74bde0269fd8d (patch)
tree181e2ab65b7bfcd5c10fb47181285a0d509e3a65
parente000c3fc5d2b2b1a6e46902f381cccdf16a38988 (diff)
Fix InstallAction type when updating components
Components should be selected for update using model, not components own check state so model values stay in sync. Wrong InstallAction type will cause component to think it will be installed when that is not the case. This caused problems in install scripts when trying to figure out if component is going to be installed or not. Task-number: QTIFW-1830 Change-Id: I367f476de96f27b27d74e06a6fb630f0876924d2 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
-rw-r--r--src/libs/installer/packagemanagercore.cpp13
-rw-r--r--tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp10
2 files changed, 17 insertions, 6 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index bb9608505..913666068 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -2256,6 +2256,8 @@ bool PackageManagerCore::updateComponentsSilently(const QStringList &componentsT
throw Error(tr("Running processes found."));
setUpdater();
+ ComponentModel *model = updaterComponentModel();
+
fetchRemotePackagesTree();
// List contains components containing update, if essential found contains only essential component
const QList<QInstaller::Component*> componentList = componentsMarkedForInstallation();
@@ -2277,15 +2279,16 @@ bool PackageManagerCore::updateComponentsSilently(const QStringList &componentsT
QList<Component*> componentsToBeUpdated;
//Mark components to be updated
foreach (Component *comp, componentList) {
+ const QModelIndex &idx = model->indexFromComponentName(comp->name());
if (!userSelectedComponents) { // No components given, update all
- comp->setCheckState(Qt::Checked);
+ model->setData(idx, Qt::Checked, Qt::CheckStateRole);
} else {
//Collect the componets to list which we want to update
foreach (const QString &name, componentsToUpdate) {
if (comp->name() == name)
componentsToBeUpdated.append(comp);
else
- comp->setCheckState(Qt::Unchecked);
+ model->setData(idx, Qt::Unchecked, Qt::CheckStateRole);
}
}
}
@@ -2295,8 +2298,10 @@ bool PackageManagerCore::updateComponentsSilently(const QStringList &componentsT
<< "No updates available for selected components.";
return false;
}
- foreach (Component *componentToUpdate, componentsToBeUpdated)
- componentToUpdate->setCheckState(Qt::Checked);
+ foreach (Component *componentToUpdate, componentsToBeUpdated) {
+ const QModelIndex &idx = model->indexFromComponentName(componentToUpdate->name());
+ model->setData(idx, Qt::Checked, Qt::CheckStateRole);
+ }
}
if (d->calculateComponentsAndRun()) {
diff --git a/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp b/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
index bf6d8729a..e260ab175 100644
--- a/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
+++ b/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
@@ -73,12 +73,18 @@ private slots:
setRepository(":///data/installPackagesRepositoryUpdate");
core->updateComponentsSilently(QStringList() << "componentA");
+ // componentD is autodependent and cannot be deselected
+ // componentE is a forced component and thus will be updated
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "2.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentD", "2.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "2.0.0content.txt");
VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentA", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentD", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentE", "1.0.0content.txt");
VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentA_update.txt"
- << "installcontentE.txt" << "installcontentG.txt"
- << "installcontentB.txt" << "installcontentD.txt");
+ << "installcontentE_update.txt" << "installcontentG.txt"
+ << "installcontentB.txt" << "installcontentD_update.txt");
}
void testUpdateNoUpdatesForSelectedPackage()