forked from qt-creator/qt-creator
Android: Unconvolute onLicenseStdOut()
Drop notify arg and dispatch it on the caller side. Return std::optional<QString> and pass the cached output in case of assertion. Change-Id: I4e738148ef248bd85a3a9260c07af30bf1586805 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -46,22 +46,16 @@ static const QRegularExpression &assertionRegExp()
|
|||||||
return theRegExp;
|
return theRegExp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool onLicenseStdOut(const QString &output, bool notify, QString *licenseTextCache,
|
static std::optional<QString> onLicenseStdOut(const QString &output, QString *licenseTextCache)
|
||||||
AndroidSdkManager::OperationOutput &result, SdkCmdPromise &fi)
|
|
||||||
{
|
{
|
||||||
licenseTextCache->append(output);
|
licenseTextCache->append(output);
|
||||||
const QRegularExpressionMatch assertionMatch = assertionRegExp().match(*licenseTextCache);
|
const QRegularExpressionMatch assertionMatch = assertionRegExp().match(*licenseTextCache);
|
||||||
if (assertionMatch.hasMatch()) {
|
if (assertionMatch.hasMatch()) {
|
||||||
if (notify) {
|
const QString ret = *licenseTextCache;
|
||||||
result.stdOutput = *licenseTextCache;
|
|
||||||
fi.addResult(result);
|
|
||||||
}
|
|
||||||
// Clear the current contents. The found license text is dispatched. Continue collecting the
|
|
||||||
// next license text.
|
|
||||||
licenseTextCache->clear();
|
licenseTextCache->clear();
|
||||||
return true;
|
return ret;
|
||||||
}
|
}
|
||||||
return false;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseProgress(const QString &out, bool &foundAssertion)
|
int parseProgress(const QString &out, bool &foundAssertion)
|
||||||
@@ -546,9 +540,14 @@ 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());
|
||||||
bool assertionFound = false;
|
std::optional<QString> assertion;
|
||||||
if (!stdOut.isEmpty())
|
if (!stdOut.isEmpty()) {
|
||||||
assertionFound = onLicenseStdOut(stdOut, reviewingLicenses, &licenseTextCache, result, fi);
|
assertion = onLicenseStdOut(stdOut, &licenseTextCache);
|
||||||
|
if (assertion && reviewingLicenses) {
|
||||||
|
result.stdOutput = *assertion;
|
||||||
|
fi.addResult(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (reviewingLicenses) {
|
if (reviewingLicenses) {
|
||||||
// Check user input
|
// Check user input
|
||||||
@@ -560,7 +559,7 @@ void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdPromise &fi)
|
|||||||
if (steps != -1)
|
if (steps != -1)
|
||||||
fi.setProgressValue(qRound((inputCounter / (double)steps) * 100));
|
fi.setProgressValue(qRound((inputCounter / (double)steps) * 100));
|
||||||
}
|
}
|
||||||
} else if (assertionFound) {
|
} else if (assertion) {
|
||||||
// The first assertion is to start reviewing licenses. Always accept.
|
// The first assertion is to start reviewing licenses. Always accept.
|
||||||
reviewingLicenses = true;
|
reviewingLicenses = true;
|
||||||
static const QRegularExpression reg(R"((\d+\sof\s)(?<steps>\d+))");
|
static const QRegularExpression reg(R"((\d+\sof\s)(?<steps>\d+))");
|
||||||
|
|||||||
Reference in New Issue
Block a user