From eaa5b874e6ea47f3ec8692a401e38156e63b5f5b Mon Sep 17 00:00:00 2001 From: Arttu Tarkiainen Date: Thu, 2 Feb 2023 15:24:39 +0200 Subject: Fix updating of install action states for components The states were only updated at the end of PackageManagerCore ::recalculateAllComponents() method - the method calls: PackageManagerCore::calculateComponentsToInstall() and PackageManagerCore::calculateComponentsToUninstall() functions in that order, and both emit signals indicating the finishing of the calculation. Any install script connecting to these signals that relies on the correct state of the install actions for the components would work incorrectly, as the state was not updated to reflect the calculation result yet. Fix by updating the install action state in both functions before emitting their finished signals. Also rename the function to better distinguish its purpose from updating the check state of the components. Task-number: QTIFW-2976 Change-Id: I67cd88478c39215ec124a5451c1f29a63cb1c82c Reviewed-by: Katja Marttila --- src/libs/installer/packagemanagercore.cpp | 6 ++++-- src/libs/installer/packagemanagercore_p.cpp | 2 +- src/libs/installer/packagemanagercore_p.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/libs') diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index db6c692e2..6a449c69a 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -633,8 +633,6 @@ bool PackageManagerCore::recalculateAllComponents() if (!isInstaller() && !calculateComponentsToUninstall()) return false; - // update install actions - d->updateComponentCheckedState(); // update all nodes uncompressed size foreach (Component *const component, components(ComponentType::Root)) component->updateUncompressedSize(); // this is a recursive call @@ -2186,6 +2184,8 @@ bool PackageManagerCore::calculateComponentsToInstall() const const bool componentsToInstallCalculated = d->installerCalculator()->appendComponentsToInstall(selectedComponentsToInstall); + d->updateComponentInstallActions(); + emit finishedCalculateComponentsToInstall(); return componentsToInstallCalculated; } @@ -2291,6 +2291,8 @@ bool PackageManagerCore::calculateComponentsToUninstall() const const bool componentsToUninstallCalculated = d->uninstallerCalculator()->appendComponentsToUninstall(selectedComponentsToUninstall); + d->updateComponentInstallActions(); + emit finishedCalculateComponentsToUninstall(); return componentsToUninstallCalculated; } diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 6d56791a0..cce093dc2 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -2922,7 +2922,7 @@ void PackageManagerCorePrivate::storeCheckState() m_coreCheckedHash.insert(component, component->checkState()); } -void PackageManagerCorePrivate::updateComponentCheckedState() +void PackageManagerCorePrivate::updateComponentInstallActions() { for (Component *component : m_core->components(PackageManagerCore::ComponentType::All)) { component->setInstallAction(component->isInstalled() diff --git a/src/libs/installer/packagemanagercore_p.h b/src/libs/installer/packagemanagercore_p.h index aaf9e27be..f316d0363 100644 --- a/src/libs/installer/packagemanagercore_p.h +++ b/src/libs/installer/packagemanagercore_p.h @@ -274,7 +274,7 @@ private: void commitPendingUnstableComponents(); void createAutoDependencyHash(const QString &componentName, const QString &oldValue, const QString &newValue); void createLocalDependencyHash(const QString &componentName, const QString &dependencies); - void updateComponentCheckedState(); + void updateComponentInstallActions(); // remove once we deprecate isSelected, setSelected etc... void restoreCheckState(); -- cgit v1.2.3