forked from qt-creator/qt-creator
Link with Qt: Prepare for sdktool to move to a different location
When linking we should now consider the new sdktool location within the Qt installation first. The new location of QtCreator.ini will be <Qt>/ Tools/sdktool/QtProject/QtCreator.ini on macOS, and <Qt>/Tools/sdktool/ share/qtcreator/QtProject/QtCreator.ini on Windows/Linux. When resolving an existing install settings path to the old location within the Qt Creator installation (Qt Creator.app/Contents/Resources or Tools/QtCreator/share/qtcreator), the QtCreator.ini at that location will itself redirect to the new sdktool location. So, try to follow that as well, to keep existing setups working. Task-number: QTBUG-28101 Change-Id: Idbb09ad6961f6fd4a4112830959a615d8186a132 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -244,22 +244,35 @@ static void setupInstallSettings(QString &installSettingspath)
|
|||||||
QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR), QLatin1String(Core::Constants::IDE_CASED_ID)));
|
QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR), QLatin1String(Core::Constants::IDE_CASED_ID)));
|
||||||
installSettingspath.clear();
|
installSettingspath.clear();
|
||||||
}
|
}
|
||||||
// Check if the default install settings contain a setting for the actual install settings.
|
|
||||||
// This can be an absolute path, or a path relative to applicationDirPath().
|
|
||||||
// The result is interpreted like -settingspath, but for SystemScope
|
|
||||||
static const char kInstallSettingsKey[] = "Settings/InstallSettings";
|
static const char kInstallSettingsKey[] = "Settings/InstallSettings";
|
||||||
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope,
|
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope,
|
||||||
installSettingspath.isEmpty() ? resourcePath() : installSettingspath);
|
installSettingspath.isEmpty() ? resourcePath() : installSettingspath);
|
||||||
|
|
||||||
QSettings installSettings(QSettings::IniFormat, QSettings::UserScope,
|
// Check if the default install settings contain a setting for the actual install settings.
|
||||||
|
// This can be an absolute path, or a path relative to applicationDirPath().
|
||||||
|
// The result is interpreted like -settingspath, but for SystemScope.
|
||||||
|
//
|
||||||
|
// Through the sdktool split that is upcoming, the new install settings might redirect
|
||||||
|
// yet a second time. So try this a few times.
|
||||||
|
// (Only the first time with QSettings::UserScope, to allow setting the install settings path
|
||||||
|
// in the user settings.)
|
||||||
|
QSettings::Scope scope = QSettings::UserScope;
|
||||||
|
int count = 0;
|
||||||
|
bool containsInstallSettingsKey = false;
|
||||||
|
do {
|
||||||
|
QSettings installSettings(QSettings::IniFormat, scope,
|
||||||
QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR),
|
QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR),
|
||||||
QLatin1String(Core::Constants::IDE_CASED_ID));
|
QLatin1String(Core::Constants::IDE_CASED_ID));
|
||||||
if (installSettings.contains(kInstallSettingsKey)) {
|
containsInstallSettingsKey = installSettings.contains(kInstallSettingsKey);
|
||||||
QString installSettingsPath = installSettings.value(kInstallSettingsKey).toString();
|
if (containsInstallSettingsKey) {
|
||||||
if (QDir::isRelativePath(installSettingsPath))
|
QString newInstallSettingsPath = installSettings.value(kInstallSettingsKey).toString();
|
||||||
installSettingsPath = applicationDirPath() + '/' + installSettingsPath;
|
if (QDir::isRelativePath(newInstallSettingsPath))
|
||||||
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, installSettingsPath);
|
newInstallSettingsPath = applicationDirPath() + '/' + newInstallSettingsPath;
|
||||||
|
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, newInstallSettingsPath);
|
||||||
}
|
}
|
||||||
|
scope = QSettings::SystemScope; // UserScope only the first time we check
|
||||||
|
++count;
|
||||||
|
} while (containsInstallSettingsKey && count < 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Utils::QtcSettings *createUserSettings()
|
static Utils::QtcSettings *createUserSettings()
|
||||||
|
@@ -897,9 +897,9 @@ void QtOptionsPageWidget::apply()
|
|||||||
&QtOptionsPageWidget::updateQtVersions);
|
&QtOptionsPageWidget::updateQtVersions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO whenever we move the output of sdktool to a different location in the installer,
|
|
||||||
// this needs to be adapted accordingly
|
|
||||||
const QStringList kSubdirsToCheck = {"",
|
const QStringList kSubdirsToCheck = {"",
|
||||||
|
"Tools/sdktool", // macOS
|
||||||
|
"Tools/sdktool/share/qtcreator", // Windows/Linux
|
||||||
"Qt Creator.app/Contents/Resources",
|
"Qt Creator.app/Contents/Resources",
|
||||||
"Contents/Resources",
|
"Contents/Resources",
|
||||||
"Tools/QtCreator/share/qtcreator",
|
"Tools/QtCreator/share/qtcreator",
|
||||||
|
Reference in New Issue
Block a user