mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +08:00
Made value object regular expressions thread safe
(note: which is important because the RegEx is static)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f8c83ce2a3
commit
e3b0720295
@@ -150,15 +150,21 @@ namespace BlackMisc
|
||||
|
||||
bool CAircraftIcaoCode::isValidDesignator(const QString &designator)
|
||||
{
|
||||
static const QRegularExpression regexp("^[A-Z]+[A-Z0-9]*$");
|
||||
if (designator.length() < 2 || designator.length() > 5) { return false; }
|
||||
|
||||
static QThreadStorage<QRegularExpression> tsRegex;
|
||||
if (! tsRegex.hasLocalData()) { tsRegex.setLocalData(QRegularExpression("^[A-Z]+[A-Z0-9]*$")); }
|
||||
const QRegularExpression ®exp = tsRegex.localData();
|
||||
return (regexp.match(designator).hasMatch());
|
||||
}
|
||||
|
||||
bool CAircraftIcaoCode::isValidCombinedType(const QString &combinedType)
|
||||
{
|
||||
static const QRegularExpression regexp("^[A-Z][0-9][A-Z]$");
|
||||
if (combinedType.length() != 3) return false;
|
||||
if (combinedType.length() != 3) { return false; }
|
||||
|
||||
static QThreadStorage<QRegularExpression> tsRegex;
|
||||
if (! tsRegex.hasLocalData()) { tsRegex.setLocalData(QRegularExpression("^[A-Z][0-9][A-Z]$")); }
|
||||
const QRegularExpression ®exp = tsRegex.localData();
|
||||
return (regexp.match(combinedType).hasMatch());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user