Android: Move a global regexp variable into a function

Change-Id: I888e11b2e16553cd14e4e07335ef90b8094b6cbf
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2023-02-10 16:56:42 +01:00
committed by Alessandro Portale
parent c2cfe596b9
commit 7faad7b4e8

View File

@@ -26,6 +26,8 @@
# include "androidplugin.h" # include "androidplugin.h"
#endif // WITH_TESTS #endif // WITH_TESTS
using namespace Utils;
namespace { namespace {
static Q_LOGGING_CATEGORY(sdkManagerLog, "qtc.android.sdkManager", QtWarningMsg) static Q_LOGGING_CATEGORY(sdkManagerLog, "qtc.android.sdkManager", QtWarningMsg)
} }
@@ -41,14 +43,17 @@ const char commonArgsKey[] = "Common Arguments:";
const int sdkManagerCmdTimeoutS = 60; const int sdkManagerCmdTimeoutS = 60;
const int sdkManagerOperationTimeoutS = 600; const int sdkManagerOperationTimeoutS = 600;
Q_GLOBAL_STATIC_WITH_ARGS(QRegularExpression, assertionReg,
("(\\(\\s*y\\s*[\\/\\\\]\\s*n\\s*\\)\\s*)(?<mark>[\\:\\?])",
QRegularExpression::CaseInsensitiveOption
| QRegularExpression::MultilineOption))
using namespace Utils;
using SdkCmdFutureInterface = QFutureInterface<AndroidSdkManager::OperationOutput>; using SdkCmdFutureInterface = QFutureInterface<AndroidSdkManager::OperationOutput>;
static const QRegularExpression &assertionRegExp()
{
static const QRegularExpression theRegExp
(R"((\(\s*y\s*[\/\\]\s*n\s*\)\s*)(?<mark>[\:\?]))", // (y/N)?
QRegularExpression::CaseInsensitiveOption | QRegularExpression::MultilineOption);
return theRegExp;
}
/*! /*!
Parses the \a line for a [spaces]key[spaces]value[spaces] pattern and returns Parses the \a line for a [spaces]key[spaces]value[spaces] pattern and returns
\c true if \a key is found, false otherwise. Result is copied into \a value. \c true if \a key is found, false otherwise. Result is copied into \a value.
@@ -79,7 +84,7 @@ int parseProgress(const QString &out, bool &foundAssertion)
progress = -1; progress = -1;
} }
if (!foundAssertion) if (!foundAssertion)
foundAssertion = assertionReg->match(line).hasMatch(); foundAssertion = assertionRegExp().match(line).hasMatch();
} }
return progress; return progress;
} }
@@ -1094,7 +1099,7 @@ bool AndroidSdkManagerPrivate::onLicenseStdOut(const QString &output, bool notif
SdkCmdFutureInterface &fi) SdkCmdFutureInterface &fi)
{ {
m_licenseTextCache.append(output); m_licenseTextCache.append(output);
QRegularExpressionMatch assertionMatch = assertionReg->match(m_licenseTextCache); const QRegularExpressionMatch assertionMatch = assertionRegExp().match(m_licenseTextCache);
if (assertionMatch.hasMatch()) { if (assertionMatch.hasMatch()) {
if (notify) { if (notify) {
result.stdOutput = m_licenseTextCache; result.stdOutput = m_licenseTextCache;