Archive: Avoid calling blocking stopProcess

Make Archive constructor public.
Make the caller responsible for deleting the Archive object.

Don't automatially run the unarchive process when constructing
Archive object. Provide a start() method, to be called after
the caller has connected to Archive signals.

Add Archive::isValid() method.

Remove Archive::unarchive() gui overload, as it's unused.

Make sure we don't leak the Archive object in
AndroidSdkDownloader.

Change-Id: Idf67262554cdfef50aef4a2234b6a5089110f9a2
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2022-03-24 10:29:02 +01:00
parent 41f9962ea6
commit ed94e0c066
6 changed files with 117 additions and 155 deletions

View File

@@ -54,6 +54,8 @@ AndroidSdkDownloader::AndroidSdkDownloader()
connect(&m_manager, &QNetworkAccessManager::finished, this, &AndroidSdkDownloader::downloadFinished);
}
AndroidSdkDownloader::~AndroidSdkDownloader() = default;
#if QT_CONFIG(ssl)
void AndroidSdkDownloader::sslErrors(const QList<QSslError> &sslErrors)
{
@@ -91,9 +93,12 @@ void AndroidSdkDownloader::downloadAndExtractSdk()
connect(m_progressDialog, &QProgressDialog::canceled, this, &AndroidSdkDownloader::cancel);
connect(this, &AndroidSdkDownloader::sdkPackageWriteFinished, this, [this]() {
if (!Archive::supportsFile(m_sdkFilename))
return;
const FilePath extractDir = m_sdkFilename.parentDir();
if (Archive *archive = Archive::unarchive(m_sdkFilename, extractDir)) {
connect(archive, &Archive::finished, [this, extractDir](bool success) {
m_archive.reset(new Archive(m_sdkFilename, extractDir));
if (m_archive->isValid()) {
connect(m_archive.get(), &Archive::finished, this, [this, extractDir](bool success) {
if (success) {
// Save the extraction path temporarily which can be used by sdkmanager
// to install essential packages at firt time setup.
@@ -101,7 +106,9 @@ void AndroidSdkDownloader::downloadAndExtractSdk()
extractDir.pathAppended(Constants::cmdlineToolsName));
emit sdkExtracted();
}
m_archive.release()->deleteLater();
});
m_archive->unarchive();
}
});
}