summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/packagemanagercore_p.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_p.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_p.cpp')
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index 7c3679087..79fb0c8dd 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -468,6 +468,10 @@ void PackageManagerCorePrivate::cleanUpComponentEnvironment()
// so we need to remove the current component script engine
delete m_componentScriptEngine;
m_componentScriptEngine = nullptr;
+
+ // Calculators become invalid after clearing components
+ clearInstallerCalculator();
+ clearUninstallerCalculator();
}
ScriptEngine *PackageManagerCorePrivate::componentScriptEngine() const