aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/android/androidsdkmanager.cpp
diff options
context:
space:
mode:
authorJarek Kobus <[email protected]>2024-04-15 23:22:38 +0200
committerJarek Kobus <[email protected]>2024-04-17 12:45:52 +0000
commitb8e1b33455645adb0256ff783da58b8960192224 (patch)
tree7b9241c191f3d3850bb6ddc0740eee22ee100ef1 /src/plugins/android/androidsdkmanager.cpp
parent3ea0a907209e51e3e864f2be5999bc77b1b46733 (diff)
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: <[email protected]> Reviewed-by: Alessandro Portale <[email protected]>
Diffstat (limited to 'src/plugins/android/androidsdkmanager.cpp')
-rw-r--r--src/plugins/android/androidsdkmanager.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/plugins/android/androidsdkmanager.cpp b/src/plugins/android/androidsdkmanager.cpp
index d5e1b1975b2..e51c324839a 100644
--- a/src/plugins/android/androidsdkmanager.cpp
+++ b/src/plugins/android/androidsdkmanager.cpp
@@ -46,22 +46,16 @@ static const QRegularExpression &assertionRegExp()
return theRegExp;
}
-static bool onLicenseStdOut(const QString &output, bool notify, QString *licenseTextCache,
- AndroidSdkManager::OperationOutput &result, SdkCmdPromise &fi)
+static std::optional<QString> onLicenseStdOut(const QString &output, QString *licenseTextCache)
{
licenseTextCache->append(output);
const QRegularExpressionMatch assertionMatch = assertionRegExp().match(*licenseTextCache);
if (assertionMatch.hasMatch()) {
- if (notify) {
- result.stdOutput = *licenseTextCache;
- fi.addResult(result);
- }
- // Clear the current contents. The found license text is dispatched. Continue collecting the
- // next license text.
+ const QString ret = *licenseTextCache;
licenseTextCache->clear();
- return true;
+ return ret;
}
- return false;
+ return {};
}
int parseProgress(const QString &out, bool &foundAssertion)
@@ -546,9 +540,14 @@ void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdPromise &fi)
QString licenseTextCache;
while (!licenseCommand.waitForFinished(200ms)) {
const QString stdOut = codec->toUnicode(licenseCommand.readAllRawStandardOutput());
- bool assertionFound = false;
- if (!stdOut.isEmpty())
- assertionFound = onLicenseStdOut(stdOut, reviewingLicenses, &licenseTextCache, result, fi);
+ std::optional<QString> assertion;
+ if (!stdOut.isEmpty()) {
+ assertion = onLicenseStdOut(stdOut, &licenseTextCache);
+ if (assertion && reviewingLicenses) {
+ result.stdOutput = *assertion;
+ fi.addResult(result);
+ }
+ }
if (reviewingLicenses) {
// Check user input
@@ -560,7 +559,7 @@ void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdPromise &fi)
if (steps != -1)
fi.setProgressValue(qRound((inputCounter / (double)steps) * 100));
}
- } else if (assertionFound) {
+ } else if (assertion) {
// The first assertion is to start reviewing licenses. Always accept.
reviewingLicenses = true;
static const QRegularExpression reg(R"((\d+\sof\s)(?<steps>\d+))");