diff options
author | Katja Marttila <katja.marttila@qt.io> | 2023-11-15 11:21:04 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2023-12-08 11:26:55 +0200 |
commit | 8e70a8a7287f773d9d181d2d39363328e5c0a4de (patch) | |
tree | 05b2a097a79c27e4c047725545aca5cdc64a5a3e /src/libs/installer | |
parent | 574b759b885807530de78a9689fdc34f8e9ea772 (diff) |
Prevent uninstalling forced component
If forced installation is used, then the item is uncheckable. This was
not correctly saved to component's internal variable. Also although item
is not user checkable, the check state needs to be counted in the model.
Uncheckable items might have for example child items and then the
uncheckable item is also installed (or uninstalled, depending on
selection).
Task-number: QTIFW-2589
Change-Id: I9ea967e34cf3f2048312fb5eacd6d0b397d7215c
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src/libs/installer')
-rw-r--r-- | src/libs/installer/component_p.cpp | 1 | ||||
-rw-r--r-- | src/libs/installer/componentmodel.cpp | 9 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/libs/installer/component_p.cpp b/src/libs/installer/component_p.cpp index 7cf47c925..bf3941274 100644 --- a/src/libs/installer/component_p.cpp +++ b/src/libs/installer/component_p.cpp @@ -188,6 +188,7 @@ void ComponentModelHelper::setCheckable(bool checkable) setData(Qt::Unchecked, Qt::CheckStateRole); } changeFlags(checkable, Qt::ItemIsUserCheckable); + m_componentPrivate->m_vars[scCheckable] = checkable ? scTrue : scFalse; } /*! diff --git a/src/libs/installer/componentmodel.cpp b/src/libs/installer/componentmodel.cpp index dbb80f2f6..7f9c3dcd4 100644 --- a/src/libs/installer/componentmodel.cpp +++ b/src/libs/installer/componentmodel.cpp @@ -562,12 +562,11 @@ QSet<QModelIndex> ComponentModel::updateCheckedState(const ComponentSet &compone for (int i = sortedNodes.count(); i > 0; i--) { Component * const node = sortedNodes.at(i - 1); - bool checkable = true; - if (node->value(scCheckable, scTrue).toLower() == scFalse) { - checkable = false; - } + if (!node->isEnabled() || node->isUnstable()) + continue; - if ((!node->isCheckable() && checkable) || !node->isEnabled() || node->isUnstable()) + //Do not let forced installations to be uninstalled + if (!m_core->isUpdater() && node->forcedInstallation() && (node->checkState() != Qt::Unchecked)) continue; if (!m_core->isUpdater() && !node->autoDependencies().isEmpty()) |