summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Kampas <martin.kampas@jolla.com>2018-09-27 06:53:22 +0200
committerKatja Marttila <katja.marttila@qt.io>2020-11-04 10:14:02 +0000
commit6dcbefc257895445d99deb06426607cc274fca08 (patch)
tree82c1c5ad29934be1d5724aed26ad63d2958eca25 /src
parent4be2a6ed5db2ca69bd6a2d008c1290e592eaa3f8 (diff)
Automatically uninstall unneeded virtual components
Change-Id: Ifbbfec4449a9f5b0a79269fc7ddfcc1780e762e5 Task-number: QTBUG-76210 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/uninstallercalculator.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libs/installer/uninstallercalculator.cpp b/src/libs/installer/uninstallercalculator.cpp
index 6fd63d499..4823af012 100644
--- a/src/libs/installer/uninstallercalculator.cpp
+++ b/src/libs/installer/uninstallercalculator.cpp
@@ -125,6 +125,32 @@ void UninstallerCalculator::appendComponentsToUninstall(const QList<Component*>
if (!autoDependOnList.isEmpty())
appendComponentsToUninstall(autoDependOnList);
+
+ QList<Component*> unneededVirtualList;
+ // Check for virtual components without dependees
+ foreach (Component *component, m_installedComponents) {
+ if (component->isInstalled() && component->isVirtual() && !m_componentsToUninstall.contains(component)) {
+ // Components with auto dependencies were handled in the previous step
+ if (!component->autoDependencies().isEmpty())
+ continue;
+ if (component->forcedInstallation())
+ continue;
+
+ bool required = false;
+ PackageManagerCore *core = component->packageManagerCore();
+ foreach (Component *dependee, core->dependees(component)) {
+ if (dependee->isInstalled() && !m_componentsToUninstall.contains(dependee)) {
+ required = true;
+ break;
+ }
+ }
+ if (!required)
+ unneededVirtualList.append(component);
+ }
+ }
+
+ if (!unneededVirtualList.isEmpty())
+ appendComponentsToUninstall(unneededVirtualList);
}
} // namespace QInstaller