mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55: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
@@ -168,8 +168,11 @@ namespace BlackMisc
|
||||
bool CCallsign::isValidCallsign(const QString &callsign)
|
||||
{
|
||||
// We allow all number callsigns
|
||||
static QRegularExpression regexp("^[A-Z0-9]*$");
|
||||
if (callsign.length() < 2 || callsign.length() > 10) { return false; }
|
||||
|
||||
static QThreadStorage<QRegularExpression> tsRegex;
|
||||
if (! tsRegex.hasLocalData()) { tsRegex.setLocalData(QRegularExpression("^[A-Z0-9]*$")); }
|
||||
const QRegularExpression ®exp = tsRegex.localData();
|
||||
return (regexp.match(callsign).hasMatch());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user