summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2021-04-26 16:23:00 +0300
committerKatja Marttila <katja.marttila@qt.io>2021-04-30 08:16:48 +0300
commit8119a82e950cc063df92d5c6d26cac1a3e4954ca (patch)
tree719d53efcb55610cdf875a56d3165b6d454e6330 /src/libs
parent3660ca50d05802a1f03c2c7f1ba7c1e873c01f78 (diff)
Fix values overwritten by maintenancetool
Maintenancetool has saved values, which are loaded after installer has initialized some values, overwriting the installer initial values. Fixed so that only values that are not already set in installer init will be set from maintenancetool ini file. Task-number: QTIFW-2218 Change-Id: Ide6a3f67daec81fe22d6dcde1e95a28f5ed2c53a Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp6
-rw-r--r--src/libs/installer/packagemanagercoredata.cpp20
-rw-r--r--src/libs/installer/packagemanagercoredata.h2
3 files changed, 19 insertions, 9 deletions
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index d1e482912..24a67d095 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -611,7 +611,7 @@ UninstallerCalculator *PackageManagerCorePrivate::uninstallerCalculator() const
void PackageManagerCorePrivate::initialize(const QHash<QString, QString> &params)
{
m_coreCheckedHash.clear();
- m_data = PackageManagerCoreData(params);
+ m_data = PackageManagerCoreData(params, isInstaller());
m_componentsToInstallCalculated = false;
#ifdef Q_OS_LINUX
@@ -920,8 +920,8 @@ void PackageManagerCorePrivate::readMaintenanceConfigFiles(const QString &target
const QVariantHash v = cfg.value(QLatin1String("Variables")).toHash(); // Do not change to
// QVariantMap! Breaks reading from existing .ini files, cause the variant types do not match.
for (QVariantHash::const_iterator it = v.constBegin(); it != v.constEnd(); ++it) {
- m_data.setValue(it.key(), replacePath(it.value().toString(), QLatin1String(scRelocatable),
- targetDir));
+ if (!m_data.contains(it.key()) || m_data.value(it.key()).isNull())
+ m_data.setValue(it.key(), replacePath(it.value().toString(), QLatin1String(scRelocatable), targetDir));
}
QSet<Repository> repos;
const QVariantList variants = cfg.value(QLatin1String("DefaultRepositories"))
diff --git a/src/libs/installer/packagemanagercoredata.cpp b/src/libs/installer/packagemanagercoredata.cpp
index 3326ec65e..8f6f24a09 100644
--- a/src/libs/installer/packagemanagercoredata.cpp
+++ b/src/libs/installer/packagemanagercoredata.cpp
@@ -50,14 +50,13 @@ namespace QInstaller
\internal
*/
-PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &variables)
+PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &variables, const bool isInstaller)
{
// Add user defined variables before dynamic as user settings can affect dynamic variables.
setUserDefinedVariables(variables);
addDynamicPredefinedVariables();
// Set some common variables that may used e.g. as placeholder in some of the settings variables or
// in a script or...
- addNewVariable(scTargetConfigurationFile, QLatin1String("components.xml"));
addNewVariable(QLatin1String("InstallerDirPath"), QCoreApplication::applicationDirPath());
addNewVariable(QLatin1String("InstallerFilePath"), QCoreApplication::applicationFilePath());
@@ -81,8 +80,6 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va
addNewVariable(scTitle, replaceVariables(m_settings.title()));
addNewVariable(scPublisher, m_settings.publisher());
addNewVariable(QLatin1String("Url"), m_settings.url());
- addNewVariable(scStartMenuDir, m_settings.startMenuDir());
- addNewVariable(scTargetConfigurationFile, m_settings.configurationFileName());
addNewVariable(scLogo, m_settings.logo());
addNewVariable(scWatermark, m_settings.watermark());
addNewVariable(scBanner, m_settings.banner());
@@ -92,7 +89,20 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va
if (!description.isEmpty())
addNewVariable(scRunProgramDescription, description);
- addNewVariable(scTargetDir, replaceVariables(m_settings.targetDir()));
+ // Some settings might change during install, read those settings later from
+ // maintenancetool if maintenancetool is used.
+ if (isInstaller) {
+ addNewVariable(scTargetDir, replaceVariables(m_settings.targetDir()));
+ addNewVariable(scTargetConfigurationFile, m_settings.configurationFileName());
+ addNewVariable(scStartMenuDir, m_settings.startMenuDir());
+ } else {
+#ifdef Q_OS_MACOS
+ addNewVariable(scTargetDir, QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../../..")).absoluteFilePath());
+#else
+ addNewVariable(scTargetDir, QCoreApplication::applicationDirPath());
+#endif
+
+ }
addNewVariable(scRemoveTargetDir, replaceVariables(m_settings.removeTargetDir()));
}
diff --git a/src/libs/installer/packagemanagercoredata.h b/src/libs/installer/packagemanagercoredata.h
index 32a848aed..3cfb77c95 100644
--- a/src/libs/installer/packagemanagercoredata.h
+++ b/src/libs/installer/packagemanagercoredata.h
@@ -37,7 +37,7 @@ class PackageManagerCoreData
{
public:
PackageManagerCoreData() {}
- explicit PackageManagerCoreData(const QHash<QString, QString> &variables);
+ explicit PackageManagerCoreData(const QHash<QString, QString> &variables, const bool isInstaller);
void clear();
void addDynamicPredefinedVariables();