7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-14 12:09:35 +00:00

Ensure that EDA_PATTERN_MATCH_RELATIONAL is thread-safe.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18548
This commit is contained in:
Jeff Young 2024-08-14 15:43:09 -06:00
parent 013fa4824b
commit 79ec93da4c
2 changed files with 6 additions and 6 deletions

View File

@ -245,7 +245,7 @@ bool EDA_PATTERN_MATCH_WILDCARD_ANCHORED::SetPattern( const wxString& aPattern )
bool EDA_PATTERN_MATCH_RELATIONAL::SetPattern( const wxString& aPattern )
{
bool matches = m_regex_search.Matches( aPattern );
bool matches = m_regex_search.IsValid() && m_regex_search.Matches( aPattern );
if( !matches || m_regex_search.GetMatchCount() < 5 )
return false;
@ -326,7 +326,7 @@ EDA_PATTERN_MATCH::FIND_RESULT EDA_PATTERN_MATCH_RELATIONAL::Find( const wxStrin
int EDA_PATTERN_MATCH_RELATIONAL::FindOne( const wxString& aCandidate ) const
{
bool matches = m_regex_description.Matches( aCandidate );
bool matches = m_regex_description.IsValid() && m_regex_description.Matches( aCandidate );
if( !matches )
return EDA_PATTERN_NOT_FOUND;
@ -365,9 +365,9 @@ int EDA_PATTERN_MATCH_RELATIONAL::FindOne( const wxString& aCandidate ) const
}
wxRegEx EDA_PATTERN_MATCH_RELATIONAL::m_regex_description(
const wxRegEx EDA_PATTERN_MATCH_RELATIONAL::m_regex_description(
R"((\w+)[=:]([-+]?[\d.]+)(\w*))", wxRE_ADVANCED );
wxRegEx EDA_PATTERN_MATCH_RELATIONAL::m_regex_search(
const wxRegEx EDA_PATTERN_MATCH_RELATIONAL::m_regex_search(
R"(^(\w+)(<|<=|=|>=|>)([-+]?[\d.]*)(\w*)$)", wxRE_ADVANCED );
const std::map<wxString, double> EDA_PATTERN_MATCH_RELATIONAL::m_units = {
{ wxS( "p" ), 1e-12 },

View File

@ -192,8 +192,8 @@ protected:
RELATION m_relation;
double m_value;
static wxRegEx m_regex_description;
static wxRegEx m_regex_search;
static const wxRegEx m_regex_description;
static const wxRegEx m_regex_search;
static const std::map<wxString, double> m_units;
};