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>
This commit is contained in:
Alessandro Portale
2021-08-12 19:22:41 +02:00
parent 14d1726c95
commit 99700bb009
2 changed files with 9 additions and 8 deletions

View File

@@ -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());
}
}
}