AndroidSettingsWidget: Fix some issues

1. Don't create gitCloner if we are not going to start it,
   i.e. when we early return with QMessageBox::information().
2. Pass a context object of *this into gitCloner connection.
3. Don't kill the gitCloner, deleteLater() instead.

Change-Id: Ibb68627ed8d16e2dc43c9d63761609c8b8c82db0
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-03-22 18:51:26 +01:00
parent d7bcd19db6
commit 5924716e21

View File

@@ -591,13 +591,6 @@ void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent)
return; return;
} }
const QString openSslRepo("https://github.com/KDAB/android_openssl.git");
QtcProcess *gitCloner = new QtcProcess(this);
CommandLine gitCloneCommand("git", {"clone", "--depth=1", openSslRepo, openSslPath.toString()});
gitCloner->setCommand(gitCloneCommand);
qCDebug(androidsettingswidget) << "Cloning OpenSSL repo: " << gitCloneCommand.toUserOutput();
QDir openSslDir(openSslPath.toString()); QDir openSslDir(openSslPath.toString());
const bool isEmptyDir = openSslDir.isEmpty(QDir::AllEntries | QDir::NoDotAndDotDot const bool isEmptyDir = openSslDir.isEmpty(QDir::AllEntries | QDir::NoDotAndDotDot
| QDir::Hidden | QDir::System); | QDir::Hidden | QDir::System);
@@ -618,7 +611,14 @@ void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent)
openSslProgressDialog->setWindowTitle(openSslCloneTitle); openSslProgressDialog->setWindowTitle(openSslCloneTitle);
openSslProgressDialog->setFixedSize(openSslProgressDialog->sizeHint()); openSslProgressDialog->setFixedSize(openSslProgressDialog->sizeHint());
connect(openSslProgressDialog, &QProgressDialog::canceled, gitCloner, &QtcProcess::kill); const QString openSslRepo("https://github.com/KDAB/android_openssl.git");
QtcProcess *gitCloner = new QtcProcess(this);
CommandLine gitCloneCommand("git", {"clone", "--depth=1", openSslRepo, openSslPath.toString()});
gitCloner->setCommand(gitCloneCommand);
qCDebug(androidsettingswidget) << "Cloning OpenSSL repo: " << gitCloneCommand.toUserOutput();
connect(openSslProgressDialog, &QProgressDialog::canceled, gitCloner, &QObject::deleteLater);
auto failDialog = [=](const QString &msgSuffix = {}) { auto failDialog = [=](const QString &msgSuffix = {}) {
QStringList sl; QStringList sl;
@@ -637,7 +637,7 @@ void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent)
openButton->deleteLater(); openButton->deleteLater();
}; };
connect(gitCloner, &QtcProcess::finished, [=] { connect(gitCloner, &QtcProcess::finished, this, [=] {
openSslProgressDialog->close(); openSslProgressDialog->close();
validateOpenSsl(); validateOpenSsl();
m_ui.openSslPathChooser->triggerChanged(); // After cloning, the path exists m_ui.openSslPathChooser->triggerChanged(); // After cloning, the path exists