summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2022-05-10 07:29:03 +0300
committerKatja Marttila <katja.marttila@qt.io>2022-05-13 14:32:31 +0300
commit82c175d76f1c40868b47f18d95376dce34e0416e (patch)
tree1d7c541f12f5193b381f62556854864c9c513c4e /src/libs
parente0371c9d74a3a9c971f5cae807176226158cfdde (diff)
Fix updating autodependency components
Autodependency components were always forcely updated, even if 'Deselect All' was selected in component selection page. Fixed so that the autodependency component update is updated only when one of its dependants is updated. Task-number: QTIFW-2595 Change-Id: I05ececc45ef32ff80d53b008f839b358158a3316 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/component.cpp10
-rw-r--r--src/libs/installer/component.h1
-rw-r--r--src/libs/installer/installercalculator.cpp11
-rw-r--r--src/libs/installer/installercalculator.h3
-rw-r--r--src/libs/installer/packagemanagercore.cpp5
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp2
6 files changed, 24 insertions, 8 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index d8485f02a..702dd2763 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -1505,6 +1505,16 @@ void Component::setUpdateAvailable(bool isUpdateAvailable)
}
/*!
+ Returns whether update is available for this component.
+
+ \sa {component::isUpdateAvailable}{component.isUpdateAvailable}
+*/
+bool Component::isUpdateAvailable() const
+{
+ return d->m_updateIsAvailable && !isUnstable();
+}
+
+/*!
Returns whether the user wants to install the update for this component.
\sa {component::updateRequested}{component.updateRequested}
diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h
index 1e83a1e9e..dbf604a56 100644
--- a/src/libs/installer/component.h
+++ b/src/libs/installer/component.h
@@ -194,6 +194,7 @@ public:
Q_INVOKABLE bool isFromOnlineRepository() const;
Q_INVOKABLE void setUpdateAvailable(bool isUpdateAvailable);
+ Q_INVOKABLE bool isUpdateAvailable() const;
Q_INVOKABLE bool updateRequested();
Q_INVOKABLE bool componentChangeRequested();
diff --git a/src/libs/installer/installercalculator.cpp b/src/libs/installer/installercalculator.cpp
index 60c0e5efd..21e82fc9a 100644
--- a/src/libs/installer/installercalculator.cpp
+++ b/src/libs/installer/installercalculator.cpp
@@ -41,8 +41,9 @@ namespace QInstaller {
\internal
*/
-InstallerCalculator::InstallerCalculator(const QList<Component *> &allComponents, const AutoDependencyHash &autoDependencyComponentHash)
- : m_allComponents(allComponents)
+InstallerCalculator::InstallerCalculator(PackageManagerCore *core, const QList<Component *> &allComponents, const AutoDependencyHash &autoDependencyComponentHash)
+ : m_core(core)
+ , m_allComponents(allComponents)
, m_autoDependencyComponentHash(autoDependencyComponentHash)
{
}
@@ -166,7 +167,8 @@ void InstallerCalculator::realAppendToInstallComponents(Component *component, co
}
}
} else {
- if (!component->isInstalled(version) || component->updateRequested()) {
+ if (!component->isInstalled(version)
+ || (m_core->isUpdater() && component->isUpdateAvailable())) {
m_toInstallComponentIds.insert(component->name());
m_orderedComponentsToInstall.append(component);
}
@@ -305,7 +307,8 @@ QSet<Component *> InstallerCalculator::autodependencyComponents(const bool rever
Component *autoDependComponent = PackageManagerCore::componentByName(autoDependency, m_allComponents);
if (!autoDependComponent)
continue;
- if ((!autoDependComponent->isInstalled() || autoDependComponent->updateRequested())
+ if ((!autoDependComponent->isInstalled()
+ || (m_core->isUpdater() && autoDependComponent->isUpdateAvailable()))
&& !m_toInstallComponentIds.contains(autoDependComponent->name())) {
// One of the components autodependons is requested for install, check if there
// are other autodependencies as well
diff --git a/src/libs/installer/installercalculator.h b/src/libs/installer/installercalculator.h
index 38909fde9..21b3775eb 100644
--- a/src/libs/installer/installercalculator.h
+++ b/src/libs/installer/installercalculator.h
@@ -43,7 +43,7 @@ class Component;
class INSTALLER_EXPORT InstallerCalculator
{
public:
- InstallerCalculator(const QList<Component *> &allComponents, const AutoDependencyHash &autoDependencyComponentHash);
+ InstallerCalculator(PackageManagerCore *core, const QList<Component *> &allComponents, const AutoDependencyHash &autoDependencyComponentHash);
enum InstallReasonType
{
@@ -73,6 +73,7 @@ private:
QSet<Component *> autodependencyComponents(const bool revertFromInstall);
private:
+ PackageManagerCore *m_core;
QList<Component*> m_allComponents;
QHash<Component*, QSet<Component*> > m_visitedComponents;
QList<const Component*> m_componentsForAutodepencencyCheck;
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 1b1ca1eec..8ebaefd62 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -4242,8 +4242,9 @@ bool PackageManagerCore::fetchUpdaterPackages(const PackagesList &remotes, const
return false;
component->loadComponentScript();
- if (!component->isUnstable())
+ if (!component->isUnstable() && component->autoDependencies().isEmpty())
component->setCheckState(Qt::Checked);
+ d->createDependencyHashes(component);
}
// after everything is set up, check installed components
@@ -4252,7 +4253,7 @@ bool PackageManagerCore::fetchUpdaterPackages(const PackagesList &remotes, const
return false;
// even for possible dependency we need to load the script for example to get archives
component->loadComponentScript();
- if (component->isInstalled()) {
+ if (component->isInstalled() && !component->autoDependencies().isEmpty()) {
// since we do not put them into the model, which would force a update of e.g. tri state
// components, we have to check all installed components ourselves
if (!component->isUnstable())
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index 8f59fba81..85e902ac3 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -570,7 +570,7 @@ InstallerCalculator *PackageManagerCorePrivate::installerCalculator() const
{
if (!m_installerCalculator) {
PackageManagerCorePrivate *const pmcp = const_cast<PackageManagerCorePrivate *> (this);
- pmcp->m_installerCalculator = new InstallerCalculator(
+ pmcp->m_installerCalculator = new InstallerCalculator(m_core,
m_core->components(PackageManagerCore::ComponentType::AllNoReplacements), pmcp->m_autoDependencyComponentHash);
}
return m_installerCalculator;