Add thread-safety to SCH_FIELD::IsVoid()

Fixes: lp:1822678
* https://bugs.launchpad.net/kicad/+bug/1822678
This commit is contained in:
Jon Evans 2019-04-02 19:53:06 -04:00
parent 9e240db80c
commit 948a61711d
2 changed files with 15 additions and 6 deletions

View File

@ -312,6 +312,18 @@ bool SCH_FIELD::IsHorizJustifyFlipped() const
}
bool SCH_FIELD::IsVoid() const
{
// When in UTF-8 mode, wxString puts string iterators in a linked list, and
// that linked list is not thread-safe.
std::lock_guard<std::mutex> guard( m_mutex );
size_t len = m_Text.Len();
return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) );
}
void SCH_FIELD::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
{
frame->GetCanvas()->SetMouseCapture( NULL, NULL );

View File

@ -59,6 +59,8 @@ class SCH_FIELD : public SCH_ITEM, public EDA_TEXT
wxString m_name;
mutable UNIQUE_MUTEX m_mutex;
public:
SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
const wxString& aName = wxEmptyString );
@ -113,12 +115,7 @@ public:
* Function IsVoid
* returns true if the field is either empty or holds "~".
*/
bool IsVoid() const
{
size_t len = m_Text.Len();
return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) );
}
bool IsVoid() const;
void SwapData( SCH_ITEM* aItem ) override;