summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/packagemanagercore.cpp
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2023-05-12 10:34:26 +0300
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2023-05-12 12:40:31 +0300
commit418286d1e46430f058b6dc77bce8d4cb09732cb8 (patch)
tree9154773eb9134bcdeb01913d374c160c0a55393f /src/libs/installer/packagemanagercore.cpp
parentec9d4b8cd52495d84d2b04c056965bb97d0e841e (diff)
MT: Fix segfault after repository category fetch
At the end of calculating components to install or uninstall, the check states of the components are updated in the model. The updateComponentInstallActions() asks both installer and uninstaller calculators for resolved components, but these may not be valid after new repository categories are fetched, and the component model is reset. This would result in dereferencing invalid Component pointers in some cases. The root cause was that the other calculator was not quaranteed to be cleared when another requested updating the check states. Fix by clearing both calculators before full recalculation occurs. Also clear the calculators when the component environment is reset, for correctness and to avoid bumping into the similar issue elsewhere in the code. Change-Id: Ide6a6188b9a19f4680cd79b55dcc842bbe98e174 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs/installer/packagemanagercore.cpp')
-rw-r--r--src/libs/installer/packagemanagercore.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index da5412dd7..9feb195d8 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -639,6 +639,12 @@ void PackageManagerCore::componentsToInstallNeedsRecalculation()
*/
bool PackageManagerCore::recalculateAllComponents()
{
+ // Clear previous results first, as the check states are updated
+ // at the end of both calculate methods, which refer to the results
+ // from both calculators. Needed to keep the state correct.
+ d->clearInstallerCalculator();
+ d->clearUninstallerCalculator();
+
if (!calculateComponentsToInstall())
return false;
if (!isInstaller() && !calculateComponentsToUninstall())