From 5924716e2191065f66a4a4750957c790edc5de2d Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 22 Mar 2022 18:51:26 +0100 Subject: [PATCH] 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 Reviewed-by: --- src/plugins/android/androidsettingswidget.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index 00e597b39fb..4f44cf820b7 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -591,13 +591,6 @@ void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent) 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()); const bool isEmptyDir = openSslDir.isEmpty(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); @@ -618,7 +611,14 @@ void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent) openSslProgressDialog->setWindowTitle(openSslCloneTitle); 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 = {}) { QStringList sl; @@ -637,7 +637,7 @@ void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent) openButton->deleteLater(); }; - connect(gitCloner, &QtcProcess::finished, [=] { + connect(gitCloner, &QtcProcess::finished, this, [=] { openSslProgressDialog->close(); validateOpenSsl(); m_ui.openSslPathChooser->triggerChanged(); // After cloning, the path exists