From 9dbdd261cd8813bc26b6d90a4baf23c7c6b4a778 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Thu, 12 Apr 2018 13:04:26 +0300 Subject: Fix nested autodependency uninstall Task-number: QTIFW-1114 QTBUG-67106 Change-Id: I29cdddaa81657e5fd2b9cbf343e16cc107ce6c18 Reviewed-by: Iikka Eklund --- src/libs/installer/componentmodel.cpp | 8 ++++++-- src/libs/installer/uninstallercalculator.cpp | 14 +++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'src/libs') diff --git a/src/libs/installer/componentmodel.cpp b/src/libs/installer/componentmodel.cpp index e0cc3fcd8..57fc05181 100644 --- a/src/libs/installer/componentmodel.cpp +++ b/src/libs/installer/componentmodel.cpp @@ -580,9 +580,13 @@ QSet ComponentModel::updateCheckedState(const ComponentSet &compone if (node->value(scCheckable, scTrue).toLower() == scFalse) { checkable = false; } - - if ((!node->isCheckable() && checkable) || !node->isEnabled() || !node->autoDependencies().isEmpty()) + // Let the check state to be checked up if the node is installed even if the component is not + // selectable/enabled or is installed as autodependency. Otherwise the node might not be selected + // and installer thinks it should be uninstalled. + if (!node->isInstalled() && + ((!node->isCheckable() && checkable) || !node->isEnabled() || !node->autoDependencies().isEmpty())) { continue; + } Qt::CheckState newState = state; const Qt::CheckState recentState = node->checkState(); diff --git a/src/libs/installer/uninstallercalculator.cpp b/src/libs/installer/uninstallercalculator.cpp index 2109cc8b4..5d49d37dc 100644 --- a/src/libs/installer/uninstallercalculator.cpp +++ b/src/libs/installer/uninstallercalculator.cpp @@ -99,13 +99,21 @@ void UninstallerCalculator::appendComponentsToUninstall(const QList const QString replaces = c->value(scReplaces); const QStringList possibleNames = replaces.split(QInstaller::commaRegExp(), QString::SkipEmptyParts) << c->name(); - foreach (const QString &possibleName, possibleNames) - autoDependencies.removeAll(possibleName); + foreach (const QString &possibleName, possibleNames) { + + Component *cc = PackageManagerCore::componentByName(possibleName, m_installedComponents); + if (!cc->uninstallationRequested()) { + autoDependencies.removeAll(possibleName); + } + } } // A component requested auto installation, keep it to resolve their dependencies as well. - if (!autoDependencies.isEmpty()) + // Mark it unchecked for their dependencies to know that the component is marked for uninstallation. + if (!autoDependencies.isEmpty()) { autoDependOnList.append(component); + component->setCheckState(Qt::Unchecked); + } } } -- cgit v1.2.3