diff options
author | Alessandro Portale <alessandro.portale@qt.io> | 2021-08-12 19:22:41 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@qt.io> | 2021-08-16 07:31:12 +0000 |
commit | 99700bb00961da9515b9cabc09895aa50c2decae (patch) | |
tree | e74286900529629afe66528589575c3af3071507 | |
parent | 14d1726c95ce01d3dc3699e2f05158de5cfa6635 (diff) |
Android: Enforce portable/clean Android SDK path
When reading a path from file chooser, settings or environment variable,
make sure it is portable and "clean".
Avoids extra compiler registrations, invalid Kits and similar issues.
Fixes: QTCREATORBUG-26092
Change-Id: I2a11563f40973d5f595bf00e37ff045a503aa9f7
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r-- | src/plugins/android/androidconfigurations.cpp | 6 | ||||
-rw-r--r-- | src/plugins/android/androidsettingswidget.cpp | 11 |
2 files changed, 9 insertions, 8 deletions
diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 7b00fb7f4f..c93d5a78f2 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -227,7 +227,7 @@ void AndroidConfig::load(const QSettings &settings) // user settings m_emulatorArgs = settings.value(EmulatorArgsKey, QStringList({"-netdelay", "none", "-netspeed", "full"})).toStringList(); - m_sdkLocation = FilePath::fromString(settings.value(SDKLocationKey).toString()); + m_sdkLocation = FilePath::fromUserInput(settings.value(SDKLocationKey).toString()).cleanPath(); m_customNdkList = settings.value(CustomNdkLocationsKey).toStringList(); m_sdkManagerToolArgs = settings.value(SDKManagerToolArgsKey).toStringList(); m_openJDKLocation = FilePath::fromString(settings.value(OpenJDKLocationKey).toString()); @@ -239,7 +239,7 @@ void AndroidConfig::load(const QSettings &settings) if (reader.load(FilePath::fromString(sdkSettingsFileName())) && settings.value(changeTimeStamp).toInt() != QFileInfo(sdkSettingsFileName()).lastModified().toMSecsSinceEpoch() / 1000) { // persisten settings - m_sdkLocation = FilePath::fromString(reader.restoreValue(SDKLocationKey, m_sdkLocation.toString()).toString()); + m_sdkLocation = FilePath::fromUserInput(reader.restoreValue(SDKLocationKey, m_sdkLocation.toString()).toString()).cleanPath(); m_customNdkList = reader.restoreValue(CustomNdkLocationsKey).toStringList(); m_sdkManagerToolArgs = reader.restoreValue(SDKManagerToolArgsKey, m_sdkManagerToolArgs).toStringList(); m_openJDKLocation = FilePath::fromString(reader.restoreValue(OpenJDKLocationKey, m_openJDKLocation.toString()).toString()); @@ -1024,7 +1024,7 @@ FilePath AndroidConfig::defaultSdkPath() { QString sdkFromEnvVar = QString::fromLocal8Bit(getenv("ANDROID_SDK_ROOT")); if (!sdkFromEnvVar.isEmpty()) - return Utils::FilePath::fromString(sdkFromEnvVar); + return FilePath::fromUserInput(sdkFromEnvVar).cleanPath(); // Set default path of SDK as used by Android Studio if (Utils::HostOsInfo::isMacHost()) { diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index 6c5d7ed514..f2329294c8 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -596,7 +596,7 @@ void AndroidSettingsWidget::validateOpenSsl() void AndroidSettingsWidget::onSdkPathChanged() { - const FilePath sdkPath = m_ui.SDKLocationPathChooser->filePath(); + const FilePath sdkPath = m_ui.SDKLocationPathChooser->filePath().cleanPath(); m_androidConfig.setSdkLocation(sdkPath); FilePath currentOpenSslPath = m_androidConfig.openSslLocation(); if (currentOpenSslPath.isEmpty() || !currentOpenSslPath.exists()) @@ -608,7 +608,7 @@ void AndroidSettingsWidget::onSdkPathChanged() void AndroidSettingsWidget::validateSdk() { - const FilePath sdkPath = m_ui.SDKLocationPathChooser->filePath(); + const FilePath sdkPath = m_ui.SDKLocationPathChooser->filePath().cleanPath(); m_androidConfig.setSdkLocation(sdkPath); m_androidSummary->setPointValid(SdkPathExistsRow, m_androidConfig.sdkLocation().exists()); @@ -865,14 +865,15 @@ void AndroidSettingsWidget::downloadSdk() } const QString message = tr("Download and install Android SDK Tools to: %1?") - .arg(m_ui.SDKLocationPathChooser->filePath().toUserOutput()); + .arg(m_ui.SDKLocationPathChooser->filePath().cleanPath().toUserOutput()); auto userInput = QMessageBox::information(this, AndroidSdkDownloader::dialogTitle(), message, QMessageBox::Yes | QMessageBox::No); if (userInput == QMessageBox::Yes) { if (m_javaSummary->allRowsOk()) { auto javaPath = m_ui.OpenJDKLocationPathChooser->filePath(); - m_sdkDownloader.downloadAndExtractSdk(javaPath.toString(), - m_ui.SDKLocationPathChooser->filePath().toString()); + m_sdkDownloader.downloadAndExtractSdk( + javaPath.toString(), + m_ui.SDKLocationPathChooser->filePath().cleanPath().toString()); } } } |