forked from qt-creator/qt-creator
Android: Get rid of onLicenseStdOut()
Make code more readable. Change-Id: Icc01a90d7f1469bb58fba325bca728e002c79512 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
#include "androidconfigurations.h"
|
#include "androidconfigurations.h"
|
||||||
#include "androidsdkmanager.h"
|
#include "androidsdkmanager.h"
|
||||||
#include "androidtr.h"
|
#include "androidtr.h"
|
||||||
#include "avdmanageroutputparser.h"
|
|
||||||
#include "sdkmanageroutputparser.h"
|
#include "sdkmanageroutputparser.h"
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
@@ -46,18 +45,6 @@ static const QRegularExpression &assertionRegExp()
|
|||||||
return theRegExp;
|
return theRegExp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::optional<QString> onLicenseStdOut(const QString &output, QString *licenseTextCache)
|
|
||||||
{
|
|
||||||
licenseTextCache->append(output);
|
|
||||||
const QRegularExpressionMatch assertionMatch = assertionRegExp().match(*licenseTextCache);
|
|
||||||
if (assertionMatch.hasMatch()) {
|
|
||||||
const QString ret = *licenseTextCache;
|
|
||||||
licenseTextCache->clear();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
int parseProgress(const QString &out, bool &foundAssertion)
|
int parseProgress(const QString &out, bool &foundAssertion)
|
||||||
{
|
{
|
||||||
int progress = -1;
|
int progress = -1;
|
||||||
@@ -540,13 +527,17 @@ void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdPromise &fi)
|
|||||||
QString licenseTextCache;
|
QString licenseTextCache;
|
||||||
while (!licenseCommand.waitForFinished(200ms)) {
|
while (!licenseCommand.waitForFinished(200ms)) {
|
||||||
const QString stdOut = codec->toUnicode(licenseCommand.readAllRawStandardOutput());
|
const QString stdOut = codec->toUnicode(licenseCommand.readAllRawStandardOutput());
|
||||||
std::optional<QString> assertion;
|
bool assertion = false;
|
||||||
if (!stdOut.isEmpty()) {
|
if (!stdOut.isEmpty()) {
|
||||||
assertion = onLicenseStdOut(stdOut, &licenseTextCache);
|
licenseTextCache.append(stdOut);
|
||||||
if (assertion && reviewingLicenses) {
|
assertion = assertionRegExp().match(licenseTextCache).hasMatch();
|
||||||
result.stdOutput = *assertion;
|
if (assertion) {
|
||||||
|
if (reviewingLicenses) {
|
||||||
|
result.stdOutput = licenseTextCache;
|
||||||
fi.addResult(result);
|
fi.addResult(result);
|
||||||
}
|
}
|
||||||
|
licenseTextCache.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reviewingLicenses) {
|
if (reviewingLicenses) {
|
||||||
|
|||||||
Reference in New Issue
Block a user