From ffccc5a021632ba6989575da46a74bde0269fd8d Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Fri, 5 Jun 2020 07:41:08 +0300 Subject: 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 --- src/libs/installer/packagemanagercore.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/libs/installer/packagemanagercore.cpp') 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 componentList = componentsMarkedForInstallation(); @@ -2277,15 +2279,16 @@ bool PackageManagerCore::updateComponentsSilently(const QStringList &componentsT QList 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()) { -- cgit v1.2.3