From 82e2ad0d82b3afccbda2677385364cfdb65f5ab2 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Thu, 26 Apr 2018 19:28:05 +0300 Subject: Fix nested autodependency uninstall Previous commit worked only when --show-virtual-components was uses. Task-number: QTIFW-1114 QTBUG-67106 Change-Id: I6d0649a37095b10ec9fd3a079e020f6a70345c94 Reviewed-by: Antti Kokko --- src/libs/installer/component_p.h | 3 ++- src/libs/installer/packagemanagercore_p.cpp | 4 ++++ src/libs/installer/uninstallercalculator.cpp | 9 +++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/libs/installer/component_p.h b/src/libs/installer/component_p.h index 9a5d0fd20..f6e9ac2bb 100644 --- a/src/libs/installer/component_p.h +++ b/src/libs/installer/component_p.h @@ -98,7 +98,8 @@ public: Install, Uninstall, KeepInstalled, - KeepUninstalled + KeepUninstalled, + AutodependUninstallation }; enum Column { diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index b21b32832..1cd7811c7 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -378,11 +378,15 @@ bool PackageManagerCorePrivate::buildComponentTree(QHash &c // now we can preselect components in the tree foreach (QInstaller::Component *component, components) { // set the checked state for all components without child (means without tristate) + // set checked state also for installed virtual tristate componets as otherwise + // those will be uninstalled if (component->isCheckable() && !component->isTristate()) { if (component->isDefault() && isInstaller()) component->setCheckState(Qt::Checked); else if (component->isInstalled()) component->setCheckState(Qt::Checked); + } else if (component->isVirtual() && component->isInstalled() && component->isTristate()) { + component->setCheckState(Qt::Checked); } } diff --git a/src/libs/installer/uninstallercalculator.cpp b/src/libs/installer/uninstallercalculator.cpp index 5d49d37dc..597c7902f 100644 --- a/src/libs/installer/uninstallercalculator.cpp +++ b/src/libs/installer/uninstallercalculator.cpp @@ -103,16 +103,17 @@ void UninstallerCalculator::appendComponentsToUninstall(const QList Component *cc = PackageManagerCore::componentByName(possibleName, m_installedComponents); if (!cc->uninstallationRequested()) { - autoDependencies.removeAll(possibleName); + if (cc->installAction() != ComponentModelHelper::AutodependUninstallation) { + autoDependencies.removeAll(possibleName); + } } } } - // A component requested auto installation, keep it to resolve their dependencies as well. - // Mark it unchecked for their dependencies to know that the component is marked for uninstallation. + // A component requested auto uninstallation, keep it to resolve their dependencies as well. if (!autoDependencies.isEmpty()) { autoDependOnList.append(component); - component->setCheckState(Qt::Unchecked); + component->setInstallAction(ComponentModelHelper::AutodependUninstallation); } } } -- cgit v1.2.3